標籤:arc rom insert AC where 英語 group by ora sel
1 create table t_class2( 2 name varchar2(255), 3 subject varchar2(255), 4 score integer, 5 stuid integer 6 ) 7 8 insert into t_class2 values(‘張三‘,‘數學‘,89,1); 9 insert into t_class2 values(‘張三‘,‘語文‘,80,1);10 insert into t_class2 values(‘張三‘,‘英語‘,70,1);11 12 13 insert into t_class2 values(‘李四‘,‘數學‘,90,2);14 insert into t_class2 values(‘李四‘,‘語文‘,70,2);15 insert into t_class2 values(‘李四‘,‘英語‘,80,2);16 17 select * from t_class218 19 20 --計算每個人的總成績並排名 desc降序排列 sum()彙總函式求總21 select name, sum(score) sumscore from t_class2 group by name order by sumscore desc22 23 24 --計算每一個人的平均成績 avg()彙總函式求平均值25 select name, avg(score) avgscore from t_class2 group by name26 27 28 --計算每個人的單科最高成績 max()彙總函式求最大值29 select name,max(score) maxscore from t_class2 group by name30 31 32 --列出每一科成績最好的學生33 34 select c2.name, c2.subject,c2.score from t_class2 c2 ,35 ( select subject, max(score) maxscore from t_class2 group by subject) c136 where c2.subject=c1.subject and c2.score=c1.maxscore
oracle語句中的彙總函式以及分組group by的使用執行個體