Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL CASE '>' Question 1

Status
Not open for further replies.

FinalPrime

Technical User
Jul 28, 2003
50
US
For the following --test-- code I get
'incorrect syntax near >'

SELECT DataSales.SalePrice,
CASE DataSales.Saleprice
WHEN > 35000 THEN 'Sold'
ELSE 'NotSold'
END 'SaleGreater35000'
FROM DataSales
WHERE DataSales.SalePrice > 35000

Any help needed to produce > results.

thanks in advance,

finalprime
 
Code:
SELECT DataSales.SalePrice,
  CASE [!]When [/!]DataSales.Saleprice > 35000 THEN 'Sold'
  ELSE 'NotSold'
  END 'SaleGreater35000' 
FROM DataSales
WHERE DataSales.SalePrice > 35000

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
you're using simple CASE syntax, you want searched CASE syntax
Code:
SELECT SalePrice
     , CASE WHEN Saleprice > 35000 
            THEN 'Sold'
            ELSE 'NotSold'
        END AS SaleGreater35000
  FROM DataSales
 WHERE SalePrice > 35000

note, however, that you're shooting yourself in the foot with the WHERE clause

:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top