daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SQL Count() not giving desired results
  2. studentID |subjectID | attendanceStatus | classDate |
  3. 1234567      ...           1               .....
  4. 1234567      ...           0
  5.    
  6. studentID | subjectID | attendancePercentage
  7.    
  8. SELECT studentID, COUNT(attendanceStatus =  0) AS Absent,
  9. COUNT( attendanceStatus = 1) As Present
  10. FROM attendance WHERE studentID = '1234567';
  11.    
  12. SELECT  studentID ,
  13.         SUM(CASE WHEN attendanceStatus = 0 THEN 1
  14.                  ELSE 0
  15.             END) AS Absent ,
  16.         SUM(CASE WHEN attendanceStatus = 1 THEN 1
  17.                    ELSE 0
  18.               END) AS Present
  19. FROM    attendance
  20. WHERE   studentID = '1234567'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top