Avatar of malraff
malraff
Flag 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
Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Andrew Crofts

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Andrew Crofts

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Carl Tawn

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

malraff

ASKER
ahh silly me i forgot the end !

cheers andy
Pratima

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 ''
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Andrew Crofts

Thanks