I am trying to alias an IN condition to group states by region. What would be the best way to write this in SQL, as I am not able to alias on a WHERE clause?
select state_cd from table
where state_cd in (‘PA’,’NY’,’NJ’,’CT’,’RI’,’MA’,’VT’,’NH’,’ME’) Northeast;
Use the alias on the column select state_cd as Northeast
if you need to, but it can't be done on the IN
clause.
Alternatively, use a CASE
statement if you are likely to have several different variations on the state_cd
field.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments