Aggregate functions in Oracle Statements and usages of grouped group by

Source: Internet
Author: User

1 Create TableT_class2 (2Namevarchar2(255), 3Subjectvarchar2(255), 4Scoreinteger, 5Stuidinteger6 )7 8 Insert  intoT_class2Values('Zhang San','Mathematics', the,1);9 Insert  intoT_class2Values('Zhang San','language', the,1);Ten Insert  intoT_class2Values('Zhang San','English', -,1); One  A  - Insert  intoT_class2Values('John Doe','Mathematics', -,2); - Insert  intoT_class2Values('John Doe','language', -,2); the Insert  intoT_class2Values('John Doe','English', the,2); -  - Select *  fromT_class2 -  +  - --calculate each person's total and rank desc descending sort sum () aggregate function + SelectNamesum(score) Sumscore fromT_class2Group  byNameOrder  bySumscoredesc A  at  - --calculate average results for each person AVG () aggregate function averaging - SelectNameavg(score) Avgscore fromT_class2Group  byname -  -  - --calculate the max () aggregation function for each person's single highest score to find the maximum value in SelectNameMax(score) Maxscore fromT_class2Group  byname -  to  + --list the students with the best grades in each section -  the SelectC2.name, C2.subject,c2.score fromT_class2 C2, *(SelectSubjectMax(score) Maxscore fromT_class2Group  bysubject) C1 $ whereC2.subject=C1.subject andC2.score=C1.maxscore

Aggregate functions in Oracle Statements and usages of grouped group by

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.