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 (simple) 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
 
Something like this ?
SELECT firstname, lastname, IIf(some condition,'YES','NO') AS 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
 
PH,

This is great! Many thanks. Can I ask a follow up question? This is obviously not standard SQL, is it possible to achieve the same thing in SQL only?

Thanks!

Steve
"My mind, blow out the candle
 
This is JetSQL syntax and thus the "standard" SQL for this forum ...
 
Reposted in ANSI SQL forum. Thanks!

Steve
"you are the only thing that shines
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top