[SQL๋ฌธ์ ํ๊ธฐ - Advent of SQL 2025 ๐ ] ์คํฌํ๋ฅผ ์ฐ์ด๋๋ ค์
Dec 05, 2025
๋ฌธ์
๋ด๊ฐ ์์ฑํ ์ ๋ต
MySQL
: Every derived table must have its own alias
select stamp, count(*) count_bill
from (select case when total_bill >= 25 then 2
when total_bill >= 15 then 1
else 0 end stamp
from tips) st
group by stamp
order by 1;MySQL, PostgreSQL
select stamp, count(*) count_bill
from (select case when total_bill >= 25 then 2
when total_bill >= 15 then 1
else 0 end stamp
from tips)
group by stamp
order by 1;Share article