Solved

sql case help

Posted on 2011-03-10
5
172 Views
Last Modified: 2012-08-13
hi all

what is wrong with this statement?
select (case when(Forecast-salestodate) < '0' then '0' else (Forecast-salestodate))as demand from Table
0
Comment
Question by:malraff
5 Comments
 
LVL 13

Accepted Solution

by:
Philip Pinnell earned 250 total points
Comment Utility
select

case when(Forecast-salestodate) < '0'
  then '0'
  else (Forecast-salestodate)
end as demand

from Table
0
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
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

0
 

Author Comment

by:malraff
Comment Utility
ahh silly me i forgot the end !

cheers andy
0
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
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 ''
0
 
LVL 13

Expert Comment

by:Philip Pinnell
Comment Utility
Thanks
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now