亲人们,请教一个SQL语句
亲人们,我又来了!ChengJi.dbf表的结构如下:
成绩ID 班级 语文
1 1 90
2 1 92
3 1 89
4 1 93
5 1 72
6 1 87
7 1 75
8 2 89
9 2 94
10 2 67
11 2 72
12 2 85
13 2 90
14 2 85
15 3 89
16 3 86
17 3 81
18 3 74
19 3 91
20 3 96
21 3 74
我想用Select出每个班的语文成绩前三名,共9条记录(三个班,每班前三甲),请问这个语句该怎么写呢?
我用SQL Server能实现,但同样的语句在VFP里却不好使。
为了方便亲人们测试,我把测试数据发在下面了。
程序代码:
CREATE CURSOR ChengJi (成绩ID INT, 班级 INT, 语文 INT) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (1,1,90) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (2,1,92) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (3,1,89) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (4,1,93) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (5,1,72) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (6,1,87) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (7,1,75) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (8,2,89) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (9,2,94) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (10,2,67) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (11,2,72) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (12,2,85) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (13,2,90) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (14,2,85) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (15,3,89) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (16,3,86) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (17,3,81) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (18,3,74) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (19,3,91) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (20,3,96) INSERT INTO ChengJi (成绩ID, 班级, 语文) VALUES (21,3,74)
[此贴子已经被作者于2018-8-25 20:21编辑过]