Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CASE in SELECT for aliases?

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Sep 26, 2001
1,605
US
a table has clinic_name, name_f, and name_l

If the clinic_name is blank, I want to use 'name_f name_l' instead. I want to sort by this also, so can I write a CASE statement that will check if the clinic_name is null or blank and assign the alias accordingly?

Like this? (doesn't work, and I left out the concat() for the name_f & name_l)

CASE
WHEN clinic_name1 = '' THEN name_l AS title
ELSE clinic_name1 AS title
END

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Code:
CASE WHEN COALESCE(clinic_name1,'') = '' 
     THEN CONCAT(name_l,', ',name_f)
     ELSE clinic_name1 
END AS title

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top