SQL Statement Summary "constantly updated"

Source: Internet
Author: User

1: query database dbName how many tables

Select COUNT (*) from information_schema.tables where table_schema= ' dbName ';

2: Merge tables based on a field

Select Id,name,sum (operate) from test group by name;


Execution Result:


3: Use an SQL statement to find out the names of students who have more than one class per course

Select name from table group by name have min (Fenshu) >80


4: Delete the same student redundancy information except auto-numbering

Delete tablename whereAuto NumberingNot in (select min (Auto Numbering) from TableName group bySchool Number,name,Course Number,Course Name,score)

 The student table is as follows :
AutoNumber number name Course number Course name score
1 2005001 Zhang San 0001 Mathematics 69
2 2005002 John Doe 0001 Mathematics 89
3 2005001 Zhang San 0001 math

SQL Statement Summary "constantly updated"

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.