MySQL (CAPI) VC instance and Code Download (1) (3 ). 4. CREATETABLEhard (quchar (11), cochar (11), jenumeric (3, 0) insertintohardvalues (A, 1, 3) insertintoh 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?
====================================
Compile (only one statement can be used) create table hard (qu char (11), co char (11), je numeric (3, 0 )) insert into hard values ('A', '1', 3) insert into h...