日期:2014-05-17 浏览次数:21105 次
-- Create table
create table T_SALARY
(
zgh VARCHAR2(40),
fgznf VARCHAR2(4),
fgzyf VARCHAR2(2),
A1 VARCHAR2(20) default 0.00,
A2 VARCHAR2(20) default 0.00,
A3 VARCHAR2(20) default 0.00,
A4 VARCHAR2(20) default 0.00,
A5 VARCHAR2(20) default 0.00
)
INSERT INTO T_SALARY VALUES('95001','2014','1','11.00','12.00','13.00','14.00','15.00');
INSERT INTO T_SALARY VALUES('95001','2014','2','21.00','22.00','23.00','24.00','25.00');
INSERT INTO T_SALARY VALUES('95001','2014','3','31.00','32.00','33.00','34.00','35.00');
-- Create table
create table T_TABLE_ITEMS
(
wid VARCHAR2(40) not null,
col_name VARCHAR2(40) not null,
col_chname VARCHAR2(100),
is_use VARCHAR2(1)
)
INSERT INTO T_TABLE_ITEMS VALUES('1','A1','内退工资','1');
INSERT INTO T_TABLE_ITEMS VALUES('2','A2','岗位工资','1');
INSERT INTO T_TABLE_ITEMS VALUES('3','A3','薪级工资','1');
INSERT INTO T_TABLE_ITEMS VALUES('4','A4','院长基金10%','1');
INSERT INTO T_TABLE_ITEMS VALUES('5','A5','房贴','0');
select t.col_name,
t.col_chname,
(select decode(t.col_name,'A1',a1,'A2',a2,'A3',a3,'A4',a4,a5)
from T_SALARY a
where a.zgh = '95001'
and a.fgznf = '2014'
and a.fgzyf = '2') as value
from T_TABLE_ITEMS t
where t.is_use = '1'