解答

133

SQL文(クエリ)

SELECT
  p.product_name
  , SUM(s.revenue) AS sum_rev
FROM
  sample.sales AS s
  LEFT JOIN sample.customers AS c
  USING
    (user_id)
  LEFT JOIN sample.products AS p
  USING
    (product_id)
WHERE
  c.prefecture = "東京"
GROUP BY
  p.product_name
ORDER BY
  sum_rev DESC
LIMIT 3

結果テーブル

結果テーブル

サポートページに戻る