Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Kafka
- off heap memory
- colab
- Dag
- SQL
- Spark ์ค์ต
- aws
- disk spill
- DataFrame Hint
- Kubernetes
- Airflow
- Spark
- topic
- Spark SQL
- mysql
- AQE
- Spark Partitioning
- Spark Caching
- Salting
- etl
- k8s
- Speculative Execution
- ๋น ๋ฐ์ดํฐ
- backfill
- KDT_TIL
- redshift
- Docker
- CI/CD
- spark executor memory
- ๋ฐ์ดํฐ ํ์ดํ๋ผ์ธ
Archives
- Today
- Total
JUST DO IT!
SQL ํ์ต - JOIN (TIL 230511) ๋ณธ๋ฌธ
๐ KDT WEEK 6 DAY 4 TIL
- JOIN
์์
%%sql
SELECT
LEFT(ts.ts, 7) as month,
ch.channel,
COUNT(DISTINCT ch.userid) as uniqueUsers,
COUNT(DISTINCT CASE WHEN trans.amount > 0 THEN ch.userid END) as paidUsers,
ROUND(paidUsers*100.0 / NULLIF(uniqueUsers,0), 2) as conversionRate,
SUM(CASE WHEN trans.refunded is not NULL THEN trans.amount END) as grossRevenue,
SUM(CASE WHEN trans.refunded is False THEN trans.amount END) as netRevenue
FROM raw_data.session_timestamp as ts
INNER JOIN raw_data.user_session_channel as ch ON ts.sessionid = ch.sessionid
LEFT JOIN raw_data.session_transaction as trans ON ch.sessionid = trans.sessionid
GROUP BY 1,2
ORDER BY 1,2 --CREATEํ ๋์๋ ์๋ฏธ์์, DB๊ฐ ์์์ ํจ
'TIL' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
AWS EC2 ๊ธฐ๋ณธ ์ฉ์ด ๋ฐ ์ธ์คํด์ค ์์ฑํ๊ธฐ(TIL 230515) (0) | 2023.05.15 |
---|---|
SQL ํ์ต - Transaction(for Python) & ์ถ๊ฐ SQL ๋ฌธ๋ฒ (TIL 230512) (0) | 2023.05.12 |
SQL ํ์ต - GROUP BY, CTAS (TIL 230510) (0) | 2023.05.10 |
Redshift cluster ์์ฑ ๋ฐ SQL ๋ฐ์ดํฐ ํ์ง ์ฒดํฌ (TIL 230509) (0) | 2023.05.10 |
๊ด๊ณํ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ SQL ๊ทธ๋ฆฌ๊ณ AWS (TIL 230508) (0) | 2023.05.08 |