2015-08-25 52 views
0

我需要顯示類明智的出勤這樣GROUP BY上的多個條款加入

enter image description here

以dB我是有單獨的表(studentattendance),其專賣店出席這樣

enter image description here

我只是需要顯示共同學生每類出席

我試圖做查詢哪個給o本安輸出這樣

enter image description here

這是我的查詢

SELECT distinct CM.ClassName ,SB.SubjectName ,(select count(studentattendance.Day1) from studentattendance where day1 = 'P') as Present, convert(varchar(10),AttendanceDate ,126) as AttendancetimeTaken 
     from studentattendance SA inner join studentmaster SM on SA.StudentID=SM.ID join ProfessorMaster p on SA.ProfessorID =p.Id 
     join Classmaster CM on SA.ClassID = CM.ID inner join SubjectMaster SB on SA.SubjectID =SB.ID 

我需要集體課明智。我該怎麼辦呢

回答

0

通過不具有實際的表,我想作以下修改,請嘗試一下,回答我

SELECT CM.ClassName , 
SB.SubjectName , count(SA.Day1) as Present, 
convert(varchar(10),AttendanceDate , 126) as AttendancetimeTaken 
from studentattendance SA 
inner join studentmaster SM on SA.StudentID=SM.ID 
join ProfessorMaster p on SA.ProfessorID =p.Id 
join Classmaster CM on SA.ClassID = CM.ID 
inner join SubjectMaster SB on SA.SubjectID =SB.ID 
where SA.day1 = 'P' 
group by CM.ClassName, SB.SubjectName, AttendanceDate 
+0

錯誤:多部分標識符「studentattendance.Day1」無法綁定。但表和列目前 –

+0

現在請檢查它,我更新了 – Lali

+1

是的...我認爲這是我所期望的東西..感謝 –