Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

Sum and Count in Sqlite

$
0
0
This is my Presence table that tracks the students' attendence and absence

Name:  2-49-10.png
Views: 22
Size:  6.9 KB

I can display the list of attendees on a grid easily
For this I use:

Code:

StrSql = "Select Fname,  Lname , " & _
" BirthDate, classe_name, subject from Student_tbl" & _
 " left join Presence_tbl on Student_tbl.ID = Presence_tbl .PID " & _
" left join subject_tbl on Presence_tbl.subj_id = subject.id " & _
 " left join class_tbl on Presence_tbl.class_id = class_tbl.ID  " & _
  " Where Presence  = 1 and date_id = " & Lbl_Date(1).Caption
Set Rs = Cnn.OpenRecordset(StrSql)

However when I want to display the list of attendees with the number of sessions attended for each pupil, I can only get one record displayed on the grid.

Code:

StrSql = "Select Fname,  Lname , " & _
" BirthDate, classe_name, subject,  sum (presence) as presences from Student_tbl" & _
 " left join Presence_tbl on Student_tbl.ID = Presence_tbl .PID " & _
" left join subject_tbl on Presence_tbl.subj_id = subject.id " & _
 " left join class_tbl on Presence_tbl .class_id = class_tbl.ID  " & _
  " Where Presence  = 1 and date_id = " & Lbl_Date(1).Caption & " GROUP BY Fname"
Set Rs = Cnn.OpenRecordset(StrSql)

I even used
Code:

count (presence) as presences
but doesn't seem to work

thank you
Attached Images
 

Viewing all articles
Browse latest Browse all 2918


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>