我以前做的时候,是用的交叉报表,因为交叉报表的表头是pb自动生成的,所以无法得到我想要的结果,所以我用了一个很笨的方法,我先建了一个表,表的字段标签就用35岁以下、35-40……,自段中放的人数,然后再加一个职称字段,这样我们可以在统计的窗口中加一个统计按钮,按钮中的脚本就是每次先删除我们新建的表中的数据,然后从基本表中去数据插入这个新建的表中,再做一个网格式的数据窗口就可以显示了。例如:
delete from title_nl;
integer i,j,nl1,nl2,nl3,nl4,nl5,nl6,nl7,nl8,xi
string bm
xi=dw_2.rowcount()
for i=1 to xi
bm=dw_2.getitemstring(i,'titlebm')
select count(num)
into :nl1
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday))>60);
select count(num)
into :nl2
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday) )between 56 and 60);
select count(num)
into :nl3
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday) )between 51 and 55);
select count(num)
into :nl4
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday) )between 46 and 50);
select count(num)
into :nl5
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday) )between 41 and 45);
select count(num)
into :nl6
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday) )between 36 and 40);
select count(num)
into :nl7
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday) )between 31 and 35);
select count(num)
into :nl8
from teasinfo
where (titlebm=:bm)and ((year(today()) - year(teasinfo.birthday))<31);
select job,num1,num2,num3 from
(
select 职称 job1,count(job) num1 from x
where (sysdate - 出生日期)/365 < =35
group by 职称
),
(
select 职称 job2,count(job) num2 from x
where (sysdate - 出生日期)/365 =< 55 and (sysdate - 出生日期)/365 > 35
group by 职称
)
,
(
select 职称 job3,count(job) num3 from x
where (sysdate - 出生日期)/365 > 55
group by 职称
),
(select 职称 job from 职称种类表)
where job = job1(+) and job = job2(+) and job = job3(+)