Menu
Coddy logo textTech

まとめ - 上位顧客

CoddyのSQLジャーニー「応用」セクションの一部 — レッスン 27/27。

challenge icon

チャレンジ

中級

利用可能なテーブルとカラム:

  • <strong>orders</strong>: <strong>id</strong>, <strong>customer_id</strong>, <strong>amount</strong>, <strong>status</strong>

status = 'paid' の注文のみを考慮し、各 customer_id について以下を返してください:

  • customer_id
  • total_spent: amount の合計
  • pct_of_revenue: 支払い済み収益の合計に対するその顧客の割合(小数点第1位で四捨五入)

total_spent の降順で並べ替えてください。

自分で試してみよう

-- 顧客ごとに支払い済み注文を集計し、合計に対する割合を計算する

応用のすべてのレッスン