Query the names of students whose course scores exceed 80

Source: Internet
Author: User

Table structure and content

 Create   Table   If   Not   Exists  'Student '('id'  Int ( 11 ) Not   Null  Auto_increment, 'name'  Varchar ( 10 ) Not   Null , 'Subobject'  Varchar ( 10 ) Not   Null  , 'Score'  Int ( 11 ) Not   Null  ,  Primary   Key  ('Id '))  Insert  Into 'Student '('id', 'name', 'subobject', 'score ') Values  (  1 , '  James  ' , '  English  ' , 80  ),(  2 , '  James ' , '  Mathematics  ' , 79  ),(  3 , '  James  ' , '  Chinese  ' , 81  ),( 4 , '  Xiaogang  ' , '  English  ' , 80  ),(  5 , '  Xiaogang  ' , '  Mathematics  ' ,80  ),(  6 , '  Xiaogang  ' , '  Chinese  ' , 80  ),(  7 , '  Xiaohong  ' ,'  English  ' , 90  ),(  8 , '  Xiaohong  ' , '  Mathematics  ' , 90  ),(  9 ,'  Xiaohong  ' , '  Chinese  ' , 81 );

SQL statement:

 # Method 1  Select Name From Student Group   By Name Having   In (Score) > 80  # Method 2  Select   Distinct Name From Student Where Name Not   In  (  Select Name From Student Where Score <  80 ) # Method 3  Select Name From Student Where Score >  80   Group   By Name Having   Count ( * ) >  1 

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.