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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single table SQL question 1

Status
Not open for further replies.

SkydivingSteve

Technical User
Feb 20, 2004
27
GB
Let's say I've got a table called Q1. OK I really do have a table called Q1.

What I want to do is show some of the values as they appear in the table (SELECT firstname, lastname FROM Q1 WHERE somecondition).

For some of the fields I want to return a flag intstead of the field value if a condition is met so, instead of (SELECT firstname, lastname, age FROM Q1 WHERE somecondition) I want (SELECT firstname, lastname, age_over_18 FROM Q1 WHERE somecondition)

I want the output to appear something like this;

Joe Bloggs YES
John Doe NO

Any advice much appreciated!

Steve
Everything that rises must converge
 
Perhaps something like this ?
SELECT firstname, lastname
,CASE WHEN some condtion THEN 'YES' ELSE 'NO' END age_over_18
FROM Q1

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top