Count Group function: (filter out fields that are empty)Select count (Address), COUNT (*) from B_userMax () Avg () min (), SUM ()Select SUM (age), Max (age), min (age), Avg (NVL (age,0)) from B_user1 260 70) 10 37.1428571428571groupby: If the field
Find duplicate data in MySQL, delete duplicate data create table and test data * Table Structure * DROPTABLEIFEXISTS 't1'; CREATETABLEIFNOTEXISTS 't1' ('id' INT (1) NOTNULLAUTO_INCREMENT, 'name' VARCHAR (20) NOTNULL, 'add' VARCHAR (20) NOTNULL,
For example:
ID name value
1 A PP
2 A PP
3 B III
4 B PP
5 B PP
6 c pp
7 c pp
8 C III
ID is the primary key
This result is required.
ID name value
1 A PP
3 B III
4 B PP
6 c pp
8 C III
Method 1
Delete yourtable
Where [ID] Not in (
Select max ([ID])
For example:
Id name value
1 a pp
2 a pp
3 B iii
4 B pp
5 B pp
6 c pp
7 c pp
8 c iii
Id is the primary key
This result is required.
Id name value
1 a pp
3 B iii
4 B pp
6 c pp
8 c iii
Method 1
Delete YourTable
Where [id] not in (
Select max ([id])
You can use the aggregate function count (*) in Mysql to implement this function. For example, to query the records with the most frequently displayed names in the user table, you can group the records by group by name first, use count to calculate
For example, if the primary key is required to obtain such results as idnamevalue1app3biii4bpp6cpp8ciii method 1 deleteYourTablewhere [id] notin (selectmax ([id]) fromYourTablegroup
For example: id name value 1 a pp 2 a pp 3 B iii 4 B pp 5 B pp 6 c
Common SQL Problems:
Select duplicates, eliminate duplicates, and select out sequences
Example of a table: EMP
Emp_no name Age
001 Tom 17
002 Sun 14
003 Tom 15
004 Tom 16
Requirements:
List the records of all the people whose names are
Reference Address: http://blog.csdn.net/ccccalculator/article/details/70432123Because the use of group by in MySQL is always a 1055 error, which leads to the need to see what is the reason, query the relevant information, now note the notes, so that
Verification: MySQL Version 5.6Method One:Delete A from table a LEFT join (Select (ID) from table Group by Studentname,classid) b to a.id=b.id where b.id is null;Method Two:Explain delete from table where ID not in (select MiniD from (select min (id)
Pivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot (aggregate function (column) for column in (...)) As
Although the SQL statements for querying and deleting duplicate records are messy, the content is still good.
Although the SQL statements for querying and deleting duplicate records are messy, the content is still good.
For example:
Id name value
1
You can understand group by and Aggregate functions in this way, groupbyTurn http://www.cnblogs.com/wuguanglei/p/4229938.html? Utm_source = tuicool; I personally think it is quite useful.
In front of the article: It took a long time for group by to
Title: normal row/column conversion (Version 2.0)
Note: normal row/column conversion (version 1.0) only provides static and dynamic writing for SQL Server 2000, and Version 2.0 adds SQL Server 2005 related writing.
Question: Suppose there is
For example:
ID Name Value
1 a pp
2 a PP
3 B III
4 B pp
5 B pp
6 C pp
7 C pp
8 C III
ID is primary key
Ask for such a result
ID Name Value
1 a pp
3 B III
4 B pp
6 C pp
8 C III
Method 1
Delete yourtable
where [id] not in (
Select MAX ([id]) from
Method 1:1, create a temporary table and select the data you want. 2, clear the original table. 3, temporary table data import into the original table. 4. Delete the temporary table. Mysql> SELECT * FROM student;+----+------+| ID | NAME |+----+------
SQL Server row and column conversion Pivot UnPivotPivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot
Pivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot (aggregate function (column) for column in (...)) As
Pivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot (aggregate function (column) for column in (...)) As
Pivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot (aggregate function (column) for column in (...)) As
SQL Row to Column rollupPivot is used to rotate column values to column names (row to column), and SQL Server 2000 can be implemented with an aggregate function with a case statementThe general syntax for pivot is: Pivot (aggregate function (column)
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.