목록Data/SQL (27)
짜리몽땅 매거진

0. 데이터 구조주의깊게 볼만한 테이블 : ga_sess , ga_sess_hitssession 과 hit에 대한 이해1. 일별 세션 건수, 일별 방문 사용자, 사용자별 평균 세션with temp_01 as ( select to_char(date_trunc('day', visit_stime), 'yyyy-mm-dd') as d_day -- ga_sess 테이블에는 sess_id로 unique하므로 count(sess_id)와 동일 , count(distinct sess_id) as daily_sess_cnt , count(sess_id) as daily_sess_cnt_again , count(distinct user_id) as daily_user_cnt from ga.ga_sess group..

Northwind 식품업체 가상 데이터베이스를 바탕으로 현황을 분석할 수 있는 쿼리 작성 후, 간단한 시각화를 통해 대시보드를 만드는 작업을 수행했다.1. 현황 분석하기(1) 2분기 총 매출액select concat(round(sum(od.quantity*od.unit_price),1),' $') as '매출액' from orders oleft join order_details od on o.id=od.order_idwhere order_date between '2006-04-01' and '2006-06-30';round 함수를 이용해 소수점 첫째자리까지 반올림 후, concat 함수를 통해 '$' 문자와 결합해준다. (2) 상반기 월별 매출액select substr(order_date,1,7) as..

Northwind 데이터 분석 보고서 작성 Redash에서 Northwind 데이터에 대한 가설을 3개 정하고, 그 가설에 대한 핵심 지표 및 보조 지표를 설정한 뒤, 그 지표를 분석해 가설에 대한 분석 보고서 작성해보자. 보고서 순서 : '가설 수립 > 가설을 검증하기 위한 지표 선정 > 지표 측정 및 분석 > 분석 결과 및 결론(인사이트)'0. 지표에 대한 이해 지표란 기업에서 어떤 대상(서비스, 프로덕트, 사람 등)의 성과 평가를 하기 위해 사용되는 기준을 말한다. 예를 들어 새로 진행한 온라인 광고의 성과 평가를 위해 ‘노출수, CTR(Click-Through Rate, 클릭률), CVR(Conversion Rate, 전환율)’ 등을 본다고 했을 때 각각은 온라인 광고 성과 평가를 위한 지표가 ..

문제1. 폐쇄할 따릉이 정류소 찾기 1출처 : solvesql 연습문제문제 정보 : 난이도 5 / 정답률 52.50%https://solvesql.com/problems/find-unnecessary-station-1/ https://solvesql.com/problems/find-unnecessary-station-1/ solvesql.com 정답 쿼리select a.station_id, a.namefrom station ajoin station b on a.station_id != b.station_idwhere a.updated_at = 5 문제 해설 1. 주요 포인트 1 - 불일치 조건 joinjoin station b on a.station_id != b.station_id 반경 내의 다른 따..
Redash 쿼리 편집기 Northwind Database를 활용한 지표 추출하기 Northwind Database는 Northwind라는 가상의 식품회사에 대한 데이터베이스이다. 고객, 상품, 주문, 직원, 발주 등 총 20개의 테이블로 구성되어 있으며, 실제 기업의 데이터베이스와 유사한 구조로 되어있어 실무와 가까운 프로젝트를 하기에 적합하다.문제1. 상품(product)의 카테고리(category)별로, 상품 수와 평균 가격대(list_price)를 찾는 쿼리를 작성하세요.SELECT category, COUNT(*) AS product_count, AVG(list_price) AS average_priceFROM productsGROUP BY category 문제2. 2006년 1분기에 고객(cu..

문제1. 두 테이블 결합하기출처 : solvesql 연습문제문제 정보 : 난이도 2 / 정답률 31.18%https://solvesql.com/problems/join/ https://solvesql.com/problems/join/ solvesql.com 정답 쿼리select DISTINCT athlete_idfrom records a join events b on a.event_id = b.idwhere b.sport = 'Golf' 문제 해설문제2. 버뮤다 삼각지대에 들어가버린 택배출처 : solvesql 연습문제문제 정보 : 난이도 2 / 정답률 35.35%https://solvesql.com/problems/shipment-in-bermuda/ https://solvesql.com/p..

출처 : w3schoolshttps://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all SQL Tryit Editor v1.6WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object. WebSQL is supported in Chrome, Safari, Opera, and Edge(79). If you use another browser you will still be able to use our Try SQL Editor, but a different verwww.w3schools.com 문제1. Country 별로 Con..

문제1. 레스토랑의 요일별 VIP출처 : solvesql 데이터리안 sql캠프 실전반문제 정보 : 난이도 2 / 정답률 56.77%https://solvesql.com/problems/restaurant-vip/ https://solvesql.com/problems/restaurant-vip/ solvesql.com 정답 쿼리select *from tipswhere total_bill in (select max(total_bill) from tips group by day) 문제 해설 1. 주요 포인트 1 - where절 서브쿼리where total_bill in (select max(total_bill) from tips group by day) 각 요일별로 그룹핑했을 때, 가장 높은 매출금액이 to..