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

case statement in a view 1

Status
Not open for further replies.

mrsbean

Technical User
Jul 14, 2004
203
US
I have written a view with a case statement. It returns records, but it doesnt work the way I thought it would.

Code:
SELECT     TempID, DateEntered, CountEntered, DateResolved, CountResolved, CASE DateEntered WHEN isnull(DateEntered, 1) 
                      THEN DateResolved ELSE DateEntered END AS TheDate
FROM         TempDailyReport
ORDER BY DateEntered, DateResolved
I wanted TheDate column to be equal to DateResolved when there was no value found in DateEntered. It leaves it blank every time. Can anybody tell me how to fix this?

A sample of the data returned is below:

TempID DateEntered CountEntered DateResolved CountResolved TheDate
153 BLANK BLANK 1/2/2005 1 BLANK
154 BLANK BLANK 1/26/2006 1 BLANK
155 BLANK BLANK 2/14/2006 1 BLANK
1 1/2/2006 10 1/2/2006 8 1/2/2006
2 1/3/2006 8 1/3/2006 8 1/3/2006

MrsBean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top