-4
我有兩個表算術級拼貼
table a
nim 01 01 01 02 02 02 03 03 03 04 04 04 05 05 05
task t m f t m f t m f t m f t m
grade 70 80 85 75 65 75 70 80 85 70 80 84 72 50 65
注:T =任務M =中層F =壓軸
table b
nim 01 02 03 04 05
name lius leo eris calvin kevin
status A A I I A
注意:A = Avaliable,I =無效
現在我想展示
no name nim t m f t1 m1 f1 final grade
note t1= tx0.2
m1 = mx0.3
f1 = fx0.5
和狀態= A
最終 = SUM T1,M1,F1
for grade
grade a >=85
grade b>=75
grade c >=65
我卡在這裏
SELECT DISTINCT b.NIM,TM,MID,FINAL,[Poin T],[Poin M],[Poin F],FLOOR([Poin T]+[Poin M]+[Poin F])AS NilaiAkhir,
CASE WHEN ([Poin T]+[Poin M]+[Poin F])>84.9 AND ([Poin T]+[Poin M]+[Poin F])<=100 THEN 'A'
WHEN ([Poin T]+[Poin M]+[Poin F])>74.9 AND ([Poin T]+[Poin M]+[Poin F])<=85 THEN 'B'
WHEN ([Poin T]+[Poin M]+[Poin F])>64.9 AND ([Poin T]+[Poin M]+[Poin F])<=75 THEN 'C'
ELSE 'D' END AS Grade
FROM Mahasiswa a,
(SELECT NIM, TM=Nilai FROM Mahasiswa WHERE Tipe LIKE 'TM') b,
(SELECT NIM, MID=Nilai FROM Mahasiswa WHERE Tipe LIKE 'MID')c,
(SELECT NIM, FINAL=Nilai FROM Mahasiswa WHERE Tipe LIKE 'FINAL')d,
(SELECT NIM, [Poin T]=Nilai*0.2 FROM Mahasiswa WHERE Tipe LIKE 'TM')e,
(SELECT NIM, [Poin M]=Nilai*0.3 FROM Mahasiswa WHERE Tipe LIKE 'MID')f,
(SELECT NIM, [Poin F]=Nilai*0.5 FROM Mahasiswa WHERE Tipe LIKE 'FINAL')g
WHERE a.NIM=b.NIM AND a.NIM=c.NIM AND a.NIM=d.NIM AND a.NIM=e.NIM AND a.NIM=f.NIM AND a.NIM=g.NIM
學校工作?提示:JOIN和GROUP BY。 – jarlh
你能幫助我嗎?它爲我的任務工作 – d2294