Looking to Divide the Returned and Total columns, to get a return rate On the most returned products. Here is what I have, how do I add the divide function on an alias?
SELECT brand
,model
,count(*) Total
,sum(case when returned = 'Y' then 1 else 0 end) as Returned
,sum(case when returned = '' then 1 else 0 end) as Kept
FROM table
WHERE year= '2018'
AND NOT type = 's'
GROUP by model
ORDER by Returned DESC;
Thanks