[SQL๋ฌธ์ œํ’€๊ธฐ - Advent of SQL 2025 ๐ŸŽ…] ์Šคํƒฌํ”„๋ฅผ ์ฐ์–ด๋“œ๋ ค์š”

silver's avatar
Dec 05, 2025
[SQL๋ฌธ์ œํ’€๊ธฐ - Advent of SQL 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

silver