Confirmation Rate 문제 내용 Signups Table과 Confirmations Table 두개가 있을 때 모든 user에 대한 login 성공 확률을 나타내라. Signups Table Column Name Type user_id int time_stamp datetime Confirmations Table Column Name Type user_id int time_stamp datetime action ENUM ('confirmed', 'timeout') 접근 방법 union all 을 이용해서 접근 가능하다. 우선 필요한것은 Confirmations Table을 이용해서 user별 'confirmed'의 횟수와 'timeout'을 포함한 전체 횟수를 구하는 것이다. 궁극적으로 성공확..
Average Selling Price 문제 내용 아래와 같은 Table 2개가 있다. product id의 제품이 팔린 날짜의 price와 팔린 units 갯수를 곱하고 unit 하나당 팔린 가격의 평균을 구하는 query를 작성하라 접근 방법 1. 두개의 Table을 join 한다 select * from Prices a,UnitsSold b where a.product_id = b.product_id select * FROM Prices as a JOIN UnitsSold as b ON a.product_id=b.product_id 위에 두개는 동일한 inner join이다. 2. purchase_date가 start_date와 end_date 사이에 있는 경우만 추출한다. select * from..