SELECT ii.ingredient_type, sum(fh.total_order)
from first_half fh join icecream_info ii
on fh.flavor = ii.flavor
group by ingredient_type
order by sum(fh.total_order) asc
SELECT mcdp_cd as '진료과코드', count(*) as '5월예약건수'
from appointment
where date_format(apnt_ymd, '%m') = 5
group by mcdp_cd
order by count(*) asc, mcdp_cd asc
SELECT animal_type, count(*) as count
from animal_ins
group by animal_type
having animal_type in ('Cat', 'Dog')
order by animal_type asc
SELECT name, count(*)
from animal_ins
where name is not null
group by name
having count(*)>1
order by name
SELECT date_format(datetime, '%k') as HOUR, count(*) as COUNT
from animal_outs
group by HOUR
having HOUR between 9 and 19
order by date_format(datetime, '%H') asc
SELECT floor(price / 10000)*10000 as PRICE_GROUP, count(*) as PRODUCTS
from product
group by floor(price / 10000)
order by PRICE_GROUP