Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

sql case help

Posted on 2011-03-10
5
Medium Priority
?
181 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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

824 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