解答

168

SQL文(クエリ)

SELECT
  COUNT(DISTINCT user_id) AS users
FROM
  (
    SELECT
      user_id
      , order_id
      , COUNT(DISTINCT product_id) AS items_in_a_order
    FROM
      sample.sales
    GROUP BY
      user_id
      , order_id
    HAVING items_in_a_order > 1
  )

結果テーブル

結果テーブル

サポートページに戻る