TheFullMonty TheFullMonty - 6 months ago 15
SQL Question

How to give an alias column different clauses to the original

This is what i have so far

SELECT Name, Composer, Composer AS MakeOver FROM Track
WHERE Composer LIKE '%/%'
AND Composer NOT LIKE 'AC/DC'


I would like the MakeOver column to have

Like '$, %'


or something along those lines to make one composer column list composers with forward slashes and one with commas.

Answer
    SELECT Name, 
    case when Composer LIKE '%/%' then Composer end as Composer, 
    case when Composer Like '$, %'  then Composer end AS MakeOver
    FROM Track
WHERE Composer LIKE '%/%'
AND Composer NOT LIKE 'AC/DC'
Comments