Wednesday, March 28, 2012

query problem

I have a table (Product) and a Column (ReleaseDate)

and trying to run this query

select Product =
CASE ReleaseDate

WHEN datediff(d,ReleaseDate,getutcdate()) < 30 THEN 'New'
WHEN datediff(d,ReleaseDate,getutcdate()) < 90 THEN 'Recent'
ELSE 'Normal' END

and get this error

Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '<'.

any ideas

cheers!!!

Change to:

select Product=

CASEWHENdatediff(d,ReleaseDate,getutcdate())< 30THEN'New'

WHENdatediff(d,ReleaseDate,getutcdate())< 90THEN'Recent'

ELSE'Normal'END

FROM product

|||Thanks for that.. i got it sorted

No comments:

Post a Comment