MySQL (c api) VC instance and code download (1) (3)

Source: Internet
Author: User


4. Maximum sorting of query data (only one statement can be used for writing)

Create table hard (qu char (11), co char (11), je numeric (3, 0 ))

Insert into hard values ('A', '1', 3)

Insert into hard values ('A', '2', 4)

Insert into hard values ('A', '4', 2)

Insert into hard values ('A', '6', 9)

Insert into hard values ('B', '1', 4)

Insert into hard values ('B', '2', 5)

Insert into hard values ('B', '3', 6)

Insert into hard values ('C', '3', 4)

Insert into hard values ('C', '6', 7)

Insert into hard values ('C', '2', 3)

The query results are as follows:

Qu co je

---------------------------

A 6 9

A 2 4

B 3 6

B 2 5

C 6 7

C 3 4

Group by qu. In each group, the first two digits of je are the largest !!

Only one SQL statement can be used !!!

Select * from hard a where je in (select top 2 je from hard B where a. qu = B. qu order by je)

5. Are you sure you want to delete the SQL statement for Repeated Records?

How to delete a record with the same field, leaving only one record.

For example, the table test contains the id and name fields.

If there are records with the same name, only one record is left, and the remaining records are deleted.

The content of the name is not fixed, and the number of identical records is not fixed.

Is there such an SQL statement?

====================================

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.