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!

SQL view: how to use <= in case construction 1

Status
Not open for further replies.

fmientjes

Programmer
Joined
Mar 27, 2002
Messages
55
Location
NL
In a view I want to get an amount when the month is less than or equal to 3 (march).
The following code is not accepted, but I don't know why:

CASE MONTH(dbo.gbkmut.date) WHEN <=3 THEN amount ELSE 0 END AS 'YTD_03_Mar'

If I change it to "WHEN 3" it works, but only for March.
Can someone give me a hint over how to achieve the amount when the month is less than or equal to March?

Thanks,
Frans
 
Move MONTH(dbo.gbkmut.date) after WHEN :)
 
Thanks vongrunt,
That was my missing link.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top