Hi,
can any body tell me what is wrong in my sql statement
SELECT title, price,
Budget
=CASE priceWHEN price> 20.00THEN'Expensive'WHEN priceBETWEEN 10.00AND 19.99THEN'Moderate'WHEN price< 10.00THEN'Inexpensive'ELSE'Unknown'ENDFROM
titlesLine 3: Incorrect syntax near '>'.
SELECT
Budget
i am using sql server 2000
SELECT title, price, Budget=CASEWHEN price < 10.00THEN'Inexpensive'WHEN price < 20.00THEN'Moderate'WHEN priceISNULLTHEN'Unknown'ELSE'Expensive'ENDFROMtitles
I'm assuming that price is a Decimal datatype.
|||
Take the price after CASE out. There are two forms of CASE statement. Your syntax was wrong.
SELECT title, price, Budget=CASE
WHEN price> 20.00THEN'Expensive'
WHENpriceBETWEEN 10.00AND 19.99THEN'Moderate'
WHENprice< 10.00THEN'Inexpensive'
ELSE'Unknown'
ENDFROMtitles
No comments:
Post a Comment