Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. SELECT t3.cid, t3.section, (t2.numberA / t3.allStuds) as ‘%A’
  2. FROM (SELECT cid, section, sum(if(grade = ‘A’, 1, 0))numberA
  3. FROM enrollment
  4. GROUP BY cid, section) t2,
  5. (SELECT cid, section, count(*) as allStuds
  6. FROM enrollment
  7. GROUP BY cid, section) t3
  8. WHERE t2.cid = t3.cid AND t2.section = t3.section;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement