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

conditional select 1

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Can anyone help me out with some syntax on how to make a field in a returned dataset 1 if some condition is satisfied, or 0 if it's not???

ex)
SELECT col1, col2, (IF col1 >= col2 THEN 1 ELSE 0) AS condition
FROM table

Is that possible???

thx -
Paul Prewett
penny.gif
penny.gif
 
Something like this:

SELECT col1, col2, condition = CASE
WHEN col1 >= col2 THEN 1
ELSE 0
END
FROM table
 
Boy, there are some stars flying today. :)

Thanks, buddy.
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top