Solved

sql case help

Posted on 2011-03-10
5
176 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Select - Finding chars in a column 2 71
sql query help 2 62
MS SQLK Server multi-part identifier cannot be bound 5 46
Are triggers slow? 7 23
Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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 …

749 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