
程序代码:
Create cursor tt(xm C(12),语文 N(5,1),数学 N(5,1),英语 N(5,1),物理 N(5,1),化学 N(5,1),历史 N(5,1),地理 N(5,1),政治 N(5,1),生物 N(5,1),px C(20))
Insert Into tt Values("AAA",51,71,56.7,51,11,30,41,70,22,"")
Insert Into tt Values("AAB",52,78,56.7,89,12,38,48,79,28,"")
Insert Into tt Values("AAC",53,56,53,81,13,53,45,39,25,"")
Insert Into tt Values("AAD",54,54,56.7,49,14,31,46,19,22,"")
Insert Into tt Values("AAE",55,48,56.7,89,15,33,43,29,26,"")
Select * From ( ;
select xm,'语文' As xk,语文 As cj From tt Union All ;
select xm,'数学' As xk,数学 As cj From tt Union All ;
select xm,'英语' As xk,英语 As cj From tt Union All ;
select xm,'物理' As xk,物理 As cj From tt Union All ;
select xm,'化学' As xk,化学 As cj From tt Union All ;
select xm,'历史' As xk,历史 As cj From tt Union All ;
select xm,'地理' As xk,地理 As cj From tt Union All ;
select xm,'政治' As xk,政治 As cj From tt Union All ;
select xm,'生物' As xk,生物 As cj From tt) As mx Into Curs tmp1
Sele tt
Scan All
Select Top 3 xk From tmp1 Where tmp1.xm=tt.xm Order By cj Desc Into Array myArr
Repl px With myArr(1)+','+myArr(2)+','+myArr(3)
Endscan
Browse
建议原始表不要以学科建立字段,把学科和成绩做成子表,然后学生是父表,这样比较合理,后面想增加学科也更方便。结果的表其实就是行转列的形式。通过查询就可以得到。
不用SQL方式,你也可以用冒泡排序法处理,也可以的
[此贴子已经被作者于2025-3-11 14:27编辑过]