Grouping with case statements question (1.0 *)


#1

What exactly does the '1.0' in below code? It seems to run just as well without

select
case name
when 'kale-smoothie' then 'smoothie'
when 'banana-smoothie' then 'smoothie'
when 'orange-juice' then 'drink'
when 'soda' then 'drink'
when 'blt' then 'sandwich'
when 'grilled-cheese' then 'sandwich'
when 'tikka-masala' then 'dinner'
when 'chicken-parm' then 'dinner'
else 'other'
end as category, round(1.0 * sum(amount_paid) /
(select sum(amount_paid) from order_items) * 100, 2) as pct
from order_items
group by 1
order by 2 desc;


#2

It is a trick you can use to direct the SQL-engine
to round at 1 decimal behind to comma......


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.