Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Conditional SQL


Message #1 by "Martin Mannion" <mfm667@h...> on Fri, 26 Jul 2002 15:58:41
The CASE expression does what you want.

	SELECT FirstName, Surname,
		CASE WHEN datediff(d,StartDate, GetDate())>=30 THEN 'Award' ELSE 'No
Award' END as ServiceAward
	  FROM...
--
Jeff Mason			Custom Apps, Inc.
Jeff@c...

-----Original Message-----
From: Martin Mannion [mailto:mfm667@h...]
Sent: Friday, July 26, 2002 3:59 PM
To: sql language
Subject: [sql_language] Conditional SQL


Is it possible to have an ?IF-Then-Else? statement within an SQL SELECT
statement. What I am trying to do is make an SQL statement that says
something like :-

Table Columns

IDNum
FirstName
Surname
StartDate

In the resulting record set I want to show:-

FirstName, Surname, ServiceAward

Where ?ServiceAward? is something like   --- If (Date Now ? StartDate) >
30 then ?Award? ELSE ?No Award?


Please HELP !!!


  Return to Index