Solved

sql case help

Posted on 2011-03-10
5
174 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
ID: 35093302
select

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

from Table
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35093304
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
ID: 35093315
ahh silly me i forgot the end !

cheers andy
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35093325
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
ID: 35093397
Thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

803 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