Link to home
Create AccountLog in
Avatar of malraff
malraffFlag for Ireland

asked on

sql case help

hi all

what is wrong with this statement?
select (case when(Forecast-salestodate) < '0' then '0' else (Forecast-salestodate))as demand from Table
ASKER CERTIFIED SOLUTION
Avatar of Andrew Crofts
Andrew Crofts
Flag of Ukraine image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
If forecast-saletodate is a number then you need to drop the apostrophes, you also need an END:
select (case when(Forecast-salestodate) < 0 then '0' else (Forecast-salestodate) END) as demand from Table

Open in new window

Avatar of malraff

ASKER

ahh silly me i forgot the end !

cheers andy
select
(
case when(Forecast-salestodate) < 0 then 0
else (Forecast-salestodate)
end
)as demand

from Table

as your Forecast-salestodate in integer no need of ''