现有一记录表1,内容如下
字段1 100 90 80 70 60 50。
A 0 3 2 0 2 0
B 0 0 1 5 0 0
C 0 0 5 2 2 4
现想查询后显示如下表2(想显示表1中第一个及最后一个值大于0的记录字段名)
字段1 最高 最低
A 90 60
B 80 70
C 80 50
请指教在Delphi中实现该功能的完整语句(已实际编译通过的最好)
(A,B,C为记录号,大约表里有上百条记录。100,90等字段名是瞎起的,实际上字段名不能是数字。另外像select 字段1, MaxValue=(case when A100>0 then 100 when A90>0 then 90.....这种语句好像只能在SQLServer中实现,而我用的是Access数据库,想在代码中用query组件的SQl语句实现,请高手指点迷津,急用,谢谢)
字段1 100 90 80 70 60 50。
A 0 3 2 0 2 0
B 0 0 1 5 0 0
C 0 0 5 2 2 4
现想查询后显示如下表2(想显示表1中第一个及最后一个值大于0的记录字段名)
字段1 最高 最低
A 90 60
B 80 70
C 80 50
请指教在Delphi中实现该功能的完整语句(已实际编译通过的最好)
(A,B,C为记录号,大约表里有上百条记录。100,90等字段名是瞎起的,实际上字段名不能是数字。另外像select 字段1, MaxValue=(case when A100>0 then 100 when A90>0 then 90.....这种语句好像只能在SQLServer中实现,而我用的是Access数据库,想在代码中用query组件的SQl语句实现,请高手指点迷津,急用,谢谢)
select 最大,最小 from tablename where 字段1>0 and 组段N>0
nnfish(游在Code中的鱼) 这个程序A,B,C为课程名,100,90 ,80为各分数段,记录的值为该分数段有几个人。整个程序用来显示各门课所有人的最高分数段和最低分数段
如 最高分数段 最低分数段
英语 90 70
计算机 80 60
when A90>0 then 90
when A80>0 then 80
when A70>0 then 70
when A60>0 then 60
when A50>0 then 50
when A40>0 then 40
when A30>0 then 30
when A20>0 then 20
when A10>0 then 10
when A0>0 then 0 end),
MinValue=(case when A0>0 then 0
when A10>0 then 10
when A20>0 then 20
when A30>0 then 30
when A40>0 then 40
when A50>0 then 50
when A60>0 then 60
when A70>0 then 70
when A80>0 then 80
when A90>0 then 90
when A100>0 then 100 end)
from table1
在SQL Server里似乎这样能实现(听别人说的),可是我用的是Access,在Delphi中写SQL语句,该则那么办呢?望高手赐教,再次万分感谢!
把取道的最大最小插入一个变量表
我忘了Access支持存储过程不
query.sql.add(你要加的SQL);
query.open;