ѧÉúÐÅÏ¢±í£¬ÈçÏ£º ID SEX SCORE YEAR 1 ÄÐ 88 2007 2 Å® 87 2008 3 ÄÐ 89 2006 4 Å® 99 2009 5 ÄÐ 54 2007 6 Å® 56 2008
ÒªÇóͳ¼Æ³öѧÉú×ÜÈËÊý£¬ÄÐÉú×ÜÈËÊý£¬Å®Éú×ÜÈËÊý СµÜÊÇÔڸ㲻¶¨£¬Çó´ð°¸£¡Ð»Ð»select count(*) from student; select count(*) from student where sex='ÄÐ'; select count(*) from student where sex='Å®';
SQL code:
select sex,count(*) from student group by sex select count(*) as ×ÜÈËÊý from student
²»ÊÇÓÃÁ½ÌõÓï¾ä select (select count(*) from student) as total,(select count(*) from student where sex='ÄÐ') as mens,(select count(*) from student where sex='Å®') as womens from student;