Background information
A lot of duplicate data has been generated since the database was recently designed because it was poorly thought out. Now you need to delete these duplicate data, and the statement you use is the group by to complete. To
MySQL large table repeating fields How do I find it? This is a lot of people have encountered problems, below teach you a MySQL large table repeat field Query method for your reference.There is a large table in the database, and you need to find a
Normal row and column conversions
Suppose there is a student score table (TB) as follows:
Name Subject Result
John Language 74
John Math 83
John Physics 93
Dick Language 74
Dick Math 84
Dick Physics 94
*/
-- -----------------------------------------
Reprint: http://www.cnblogs.com/newwind521/archive/2010/11/25/1887203.htmlSQL row Line column conversion for normal row/*Title: Normal row and column conversions (version 2.0)Aixinjueluo. Yuk WahDate: 2008-03-09Location: Shenzhen,
--Data for the row with the largest (small) value grouped by a field
Copy Code code as follows:
/*
The data are as follows:
Name Val Memo
A 2 A2 (the second value of a)
The first value of a 1 a1--a
The third value of a 3 a3:
Introduction
It's not a matter of how deep the technical problem is, how much the ability of a fork to program. This is not necessarily directly related to a person's ability to develop, but knowing these will help you with your SQL writing, worry
The examination system has done a user to import the question function, causes the user to import many duplicate questions, I need to inquire and deletes the duplicate record, therefore has this article.
(i) a single field
1, look up the redundant
Here I will demonstrate the postgresql inside how to achieve the display of the cross table, as to what is the cross table, I do not say more, the Niang go Oh.The original table data is as follows:Click (here) to collapse or opent_girl=# select *
Here I would like to demonstrate how to achieve the cross-table in PostgreSQL display, as to what is a cross-table, I will not say, the degree Niang go oh.The original table data is as follows:t_girl=# select * from score; Name | subject | score----
Data sheet:Career change: Using Max (case and then)max---聚合函数 取最大值(casecourse when‘语文‘thenscore else0 end) ---判断 as 语文---别名作为列名SELECT ' name ', Max (case when course= ' language ' then score END ) as language, Max (
Normal row and column conversionsQuestion: Suppose there is a student score table (TB) as follows:Name Course ScoreZhang San language 74Zhang San Mathematics 83Zhang San Physics 93John Doe Language 74John Doe Mathematics 84John Doe Physics 94Want to
1. Querying dataSelect Property ListFrom table name and view list[Where Condition expression 1][Group By property name 1 [having conditional expression 2] [with rollup the last record is the sum of the above Records]]//The field specified by the
One, part of the same field to remove duplicate data method:By grouping group by repeating field the having (*) >1 condition--"Extract the duplicate field value--" Finally, based on the uniqueness of the ID--Get the value of min or Max ID in the
A few classic SQL written questions (with answers)(1) Table name: Shopping InformationNumber of shopper product namesA 2B Ethyl 4C-Propyl 1A-Butyl 2B-C 5......(The record of other user's experiment can be inserted by oneself)Give all purchased items
For example:ID Name Value1 a pp2 a PP3 B III4 B pp5 B pp6 C pp7 C pp8 C IIIID is primary keyAsk for such a resultID Name Value1 a pp3 B III4 B pp6 C pp8 C IIIMethod 1Delete yourtablewhere [id] not in (Select MAX ([id]) from yourtableGroup BY (name +
Today, my friend asked a particularly tangled question: in a database table, we need to repeat a field in the table and sort the remaining data by another field,
Today, my friend asked a particularly tangled question: in a database table, we need to
WITHROLLUP is an interesting application in MySQL's extended SQL statement. Based on the grouping statistics, the same statistics (SUM, AVG, COUNThellip;) are performed.
MySQL extended SQL has a very interesting application WITH ROLLUP. The same
When using mysql, you sometimes need to query records with unique fields. Although mysql provides the keyword distinct to filter out redundant duplicate records, only one record is retained, but it is often used to return the number of records that
There is A field & ldquo; name & rdquo; in Table A, and the value of & ldquo; name & rdquo; between different records may be the same, now you need to query the records in the table, and the & ldquo; name & rdquo; value has repeated items;
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