[SQL๋ฌธ์ œํ’€๊ธฐ - Advent of SQL 2025 ๐ŸŽ…] 12์›” ์šฐ์ˆ˜ ๊ณ ๊ฐ ์ฐพ๊ธฐ

silver's avatar
Dec 03, 2025
[SQL๋ฌธ์ œํ’€๊ธฐ - Advent of SQL 2025 ๐ŸŽ…] 12์›” ์šฐ์ˆ˜ ๊ณ ๊ฐ ์ฐพ๊ธฐ

๋ฌธ์ œ

๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ์ •๋‹ต

๊ณตํ†ต

select customer_id from records where order_date between '2020-12-01' and '2021-01-01' group by customer_id having sum(sales) >= 1000;

๋‚ ์งœ ๋ณ€ํ™˜ ๋ฉ”์„œ๋“œ ๋‹ค๋ฆ„

// MySQL select customer_id from records where date_format(order_date,'%Y%m') = '202012' group by customer_id having sum(sales) >= 1000; // PostgreSQL select customer_id from records where to_char(order_date,'yymm') = '2012' group by customer_id having sum(sales) >= 1000; // SQLite select customer_id from records where strftime('%Y-%m',order_date) = '2020-12' group by customer_id having sum(sales) >= 1000;
Share article

silver