我用的是INTERBASE
我的表的结果如下:
deptid value year
01 2000 2000
02 1500 2001
03 695 2003
01 2051 2001
02 789 2000
...................
...................
我现在想的是要把表的结果道成:
id 2000 2001 2002 .....
01 2000 2051 .....
02 789 1500 .....
............................
我知道好象是要用到存储过程,但我不会。那为大哥能不 能给说的详细一些
我的表的结果如下:
deptid value year
01 2000 2000
02 1500 2001
03 695 2003
01 2051 2001
02 789 2000
...................
...................
我现在想的是要把表的结果道成:
id 2000 2001 2002 .....
01 2000 2051 .....
02 789 1500 .....
............................
我知道好象是要用到存储过程,但我不会。那为大哥能不 能给说的详细一些
解决方案 »
- 如何让程序运行时不显示在桌面和任务栏上,而显示在状态上
- 40分求救:怎样实现现有的各控件caption显示中文,日文和韩文
- 如何做什么也看不见的隐藏程序?
- 这样的ListView如何做?(就象Windows的资源管理器那样,没有层次限制)
- 怎么在报表里显示: 2003年11月6号 这个日期...QRLabel.Caption :=DataTimePRegister ??????
- 取字段值出错!!为什么??
- 如何动态的创一个报表
- 在delphi中是用什么热键取返回值?
- 开发CDROM快捷控制的程序
- 分不多了,但问题是要解决的。我的程序到底错在哪里?????
- 关于stringgrid中有点难度的问题
- 怎样在TIMAGE中显示TREEVIEW节点前的图标?
set @sql ='select id'
select @sql=@sql+',sum(case year when '''+year+''' then value and)['+year+']'
from (select destinct year from 表 ) as a
setect @sql=@sql='from testgroup by id'
exec(@sql)
select id,sum(a) a,sum(b) b,sum(c) c,sum(d) d from
(
select id,value_num as a,0 as b,0 as c, 0 as d from table where year='2000'
union
select id,0 as a,value_num as b,0 as c, 0 as d from table where year='2001'
union
select id,0 as a,0 as b,value_num as c, 0 as d from table where year='2002'
union
select id,0 as a,0 as b,0 as c,value_num as d from table where year='2003' )
group by id