고급 SQL 시리즈

1514 단어 중얼거리다tech
SELECT
 user_id,
 DATE(created_at) AS dt,
 point AS first_point,
 device AS first_device
FROM user_login
WHERE
 id IN  -- 入れ子にしたSELECT文でグルーピングした最古のレコードのidを取得する
  (
   SELECT
    MIN(id)
   FROM user_login
   GROUP BY user_id, DATE(created_at)
  )
GROUP BY user_id, dt
;

좋은 웹페이지 즐겨찾기