Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1.  
  2. SELECT hs.*,AVG(hsm.Mark)
  3. FROM H_Students hs
  4. LEFT JOIN H_Students st_later
  5. ON st_later.UID > hs.UID AND
  6. st_later.Id = hs.Id
  7. LEFT JOIN H_StudentMarks hsm
  8. ON hsm.StudentId = hs.Id
  9. LEFT JOIN H_StudentMarks sm_later
  10. ON sm_later.UID > hsm.UID AND
  11. sm_later.StudentId = hsm.StudentId AND
  12. sm_later.SubjectID = hsm.SubjectId AND
  13. sm_later.ExamDate = hsm.ExamDate
  14. WHERE st_later.UID IS NULL AND
  15. hs.EventType <> 'D' AND
  16. sm_later.UID IS NULL AND
  17. (hsm.EventType <> 'D' OR hsm.UID IS NULL)
  18. GROUP BY hs.Id,hs.UID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement