[SQL๋ฌธ์ œํ’€๊ธฐ - Advent of SQL 2025 ๐ŸŽ…] A/B ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋ฒ„ํ‚ท ๋‚˜๋ˆ„๊ธฐ 2

silver's avatar
Dec 23, 2025
[SQL๋ฌธ์ œํ’€๊ธฐ - Advent of SQL 2025 ๐ŸŽ…] A/B ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋ฒ„ํ‚ท ๋‚˜๋ˆ„๊ธฐ 2

๋ฌธ์ œ

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

MySQL, PostgreSQL, SQLite

with a as (select *,case when customer_id%10=0 then 'A' else 'B' end bucket from transactions), b as (select customer_id, count(transaction_id) tr, sum(total_price) pr, bucket from a where not is_returned group by customer_id, bucket) select bucket, count(distinct customer_id) user_count, round(avg(tr),2) avg_orders, round(avg(pr),2) avg_revenue from b group by bucket;
Share article

silver