← ダッシュボードへ戻る
🛠️ SQL分析サンドボックス
📋 SQLテンプレート
-- テンプレートを選択 --
基本統計(正解率・平均所要時間)
詳細統計(受験者数・合計時間含む)
受験セッション一覧
未完了セッション確認
問題別難易度分析
クーポンコード別利用状況
クーポン有無別の売上比較
SELECT q.title AS 問題名, COUNT(*) AS 回答数, COUNT(DISTINCT a."examId") AS 受験セッション数, SUM(a."durationSec") AS 合計所要時間_秒, ROUND(AVG(a."durationSec"), 1) AS 平均所要時間_秒, ROUND(AVG(a."durationSec") / 60.0, 2) AS 平均所要時間_分, AVG(CASE WHEN a."isCorrect" = true THEN 1 ELSE 0 END) * 100 AS 正解率 FROM exam_answers a JOIN questions q ON a."questionId" = q.id GROUP BY q.title, q.id ORDER BY 平均所要時間_秒 DESC
▶ SQLを実行
📚 テーブル定義 (Cheatsheet)
exam_sessions
受験1回ごとの記録
id (String/CUID)
userId (String)
startedAt (DateTime)
endedAt (DateTime?)
score (Int?)
isPassed (Boolean)
questionIds (String[])
exam_answers
1問ごとの回答詳細
id (Int)
examId (FK) ※sessionId
questionId (FK)
answerSql (String) ※userSql
isCorrect (Boolean)
durationSec (Int)
questions
問題マスタ
id (String/UUID)
title (String)
text (String)
correctSql (String)
difficulty (Int)
category (String)
targetTable (String)
payments
決済履歴
id (String/CUID)
userId (String)
amount (Int) ※支払額
originalAmount (Int?) ※割引前
discountAmount (Int?) ※割引額
couponCode (String?) ※クーポン
status (String) ※succeeded等
createdAt (DateTime)
completedAt (DateTime?)
⚠️
Warning:
DELETEやUPDATEも実行可能です。本番データの操作には注意してください。