0
生のHWとテストのスコアを取得し、合計の加重平均と同様に各割り当ての割合を計算するプロシージャをSQLで記述する必要があるクラスの割り当てがあります。テーブルの主キーは生徒のSSNです。各割り当ての最大得点はSSN = '0001'の下に格納され、割り当ての重みはSSN = '0002.'の下に格納されます。私は "サブクエリが複数の行を返します"というエラーが出ています。どこが間違っているのか分かりません。誰かが私を助けることができたら、私は本当にそれを感謝します。SQLサブクエリは複数の行エラーを返します
SET hw1M = (SELECT hw1 FROM RAW_SCORES WHERE (SSN = '0001'));
SET hw1W = (SELECT hw1 FROM RAW_SCORES WHERE (SSN = '0002'));
SET hw2aM = (SELECT hw2a FROM RAW_SCORES WHERE (SSN = '0001'));
SET hw2aW = (SELECT hw2a FROM RAW_SCORES WHERE (SSN = '0002'));
SET hw2bM = (SELECT hw2b FROM RAW_SCORES WHERE (SSN = '0001'));
SET hw2bW = (SELECT hw2b FROM RAW_SCORES WHERE (SSN = '0002'));
SET MidtermM = (SELECT Midterm FROM RAW_SCORES WHERE (SSN = '0001'));
SET MidtermW = (SELECT Midterm FROM RAW_SCORES WHERE (SSN = '0002'));
SET hw3M = (SELECT HW3 FROM RAW_SCORES WHERE (SSN = '0001'));
SET hw3W = (SELECT HW3 FROM RAW_SCORES WHERE (SSN = '0002'));
SET FExamM = (SELECT FExam FROM RAW_SCORES WHERE (SSN = '0001'));
SET FExamW = (SELECT FExam FROM RAW_SCORES WHERE (SSN = '0002'));
SET HW1Pct = ((SELECT Hw1 FROM RAW_SCORES)/hw1M);
SET HW2aPct = ((SELECT Hw2a FROM RAW_SCORES)/hw2aM);
SET HW2bPct = ((SELECT Hw2b FROM RAW_SCORES)/hw2bM);
SET MidtermPct = ((SELECT Midterm FROM RAW_SCORES)/MidtermM);
SET HW3Pct = ((SELECT Hw3 FROM RAW_SCORES)/hw3M);
SET FExamPct = ((SELECT FExam FROM RAW_SCORES)/FExamM);
SET WeightedAverage = ((HW1Pct * hw1w) + (HW2Pct * hw2aw) + (HW2bPct * hw2bw) + (MidtermPct * Midtermw) + (HW3Pct * hw3w) + (FExamPct * FExamw));
SELECT SSN, FName, LName, HW1Pct, HW2Pct, MidtermPct, HW3Pct, FExamPct FROM RAW_SCORES;
あなたはセットで考えていません – Hogan