Question Locked

Query Results MS SQL 2005

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I'm trying to pull two columns (VendorName and VendorState) from the Vendors table using a UNION statement. How can I write the statement so that records with "NY" in VendorState show up as "NY", but all other states show up as "Outside NY". Thank you.

2 replies

by powlboyjr

SELECT VendorName, VendorState
FROM Vendors
WHERE VendorState IN ('NY')
UNION
SELECT VendorName, 'Outside NY' AS VendorState
FROM Vendors
WHERE VendorState NOT IN ('NY')
ORDER BY VendorName

This discussion is closed to new replies.