Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +----------+--------+
- | stu_name | stu_no |
- +----------+--------+
- | Abcd | 1 |
- | Acmn | 1 |
- | Borne | 1 |
- | Bence | 1 |
- | Lucy | 1 |
- | Jone | 2 |
- | Lucy | 2 |
- | Lily | 2 |
- +----------+--------+
- +----------+--------+
- | A | B |
- +----------+--------+
- | 2 | 2 |
- +----------+--------+
- select count(ta.stu_name) as A, count(tb.stu_name) as B from
- (select stu_name, stu_no from stuInfo where stu_no=1) filtered_table
- left join filtered_table ta on stu_name like 'A%'
- left join filtered_table tb on stu_name like 'B%';
- select count(ta.stu_name) as A, count(tb.stu_name) as B from
- (select stu_name, stu_no from stuInfo where stu_no = 1 and stu_name like 'A%') ta left join
- (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