If you use this statement in MS SQL Server:
The code is as follows |
Copy Code |
Select Top 2 * from test01 |
Oracle's statement:
The code is as follows |
Copy Code |
SELECT * FROM (select RowNum r, * from test) Ttwhere TT.R > and TT.R <= 100; |
(preferably with a plsql cursor)
In DB2:
The code is as follows |
Copy Code |
SELECT * FROM payment to fetch first 5 row only--check the top 5 records |
MSSQL
If you use this statement in MS SQL Server:
The code is as follows |
Copy Code |
Select Top 2 * from test01 |
Only the first 2 records will be displayed,
MYSQL to use limit on it.
The code is as follows |
Copy Code |
SELECT * from your_table where ... limit 2;
|
Msssql an instance
1. Use of MS SQL Server 2008;
2. The database contents are as follows: John Mathematics 98 Dick Mathematics 95 Harry Mathematics 90 Zhao Six English 100 Zhang three English 99 Li four English 69
3. Results to query: Top 2 of each course
code is as follows |
copy code |
Select A.xingming,a.kemu,a.fenshu from Xuexi a where A.fenshu in (SELECT top 2 Fenshu from Xuexi where xingming = a.xingming and Kemu=a.kemu ORDER BY Fenshu Desc) |