Guest User

Untitled

a guest
Jun 20th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. +----------+--------+
  2. | stu_name | stu_no |
  3. +----------+--------+
  4. | Abcd | 1 |
  5. | Acmn | 1 |
  6. | Borne | 1 |
  7. | Bence | 1 |
  8. | Lucy | 1 |
  9. | Jone | 2 |
  10. | Lucy | 2 |
  11. | Lily | 2 |
  12. +----------+--------+
  13.  
  14. +----------+--------+
  15. | A | B |
  16. +----------+--------+
  17. | 2 | 2 |
  18. +----------+--------+
  19.  
  20. select count(ta.stu_name) as A, count(tb.stu_name) as B from
  21. (select stu_name, stu_no from stuInfo where stu_no=1) filtered_table
  22. left join filtered_table ta on stu_name like 'A%'
  23. left join filtered_table tb on stu_name like 'B%';
  24.  
  25. select count(ta.stu_name) as A, count(tb.stu_name) as B from
  26. (select stu_name, stu_no from stuInfo where stu_no = 1 and stu_name like 'A%') ta left join
  27. (select stu_name, stu_no from stuInfo where stu_no = 1 and stu_name like 'B%') tb;
Add Comment
Please, Sign In to add comment