728x90
반응형
- 문제 - leetcode Product Sales Analysis I
Write a solution to report the product_name, year, and price for each sale_id in the Sales table.
Return the resulting table in any order.
The result format is in the following example.
sales_id 별 product_name, year, price를 반환
- 풀이
SELECT p.product_name, s.year, s.price
FROM sales s
JOIN product p
ON s.product_id=p.product_id
- 문제 - leetcode Customer Who Visited but Did Not Make Any Transactions
Write a solution to find the IDs of the users who visited without making any transactions and the number of times they made these types of visits.
Return the result table sorted in any order.
The result format is in the following example.
거래를 하지 않고 방문한 사용자의 ID와 이러한 유형의 방문 횟수를 반환
- 풀이
SELECT v.customer_id, count(*) count_no_trans
FROM visits v
LEFT JOIN transactions t
ON v.visit_id=t.visit_id
WHERE transaction_id is null
GROUP BY v.customer_id
728x90
반응형
'데이터분석 > TIL' 카테고리의 다른 글
240903 TIL (1) | 2024.09.03 |
---|---|
240814 TIL (0) | 2024.08.14 |
240808 TIL (0) | 2024.08.08 |