报表显示年龄段,高手们,救命!

tjm1 2001-12-14 07:58:42
打印的报表要求统计人数,报表如下:

35岁以下 36-45 46-55 56以上
高级职称
.......
中级职称
.......
初级职称
.......

表中有一个出生日期字段,怎么做这个报表呀?用什么数据窗口好?
...全文
165 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
longzzh 2001-12-15
  • 打赏
  • 举报
回复
例子;
This example determines the difference in days between the current date and the publication date.

SELECT newdate = DATEDIFF(day, pubdate, getdate())
FROM titles
longzzh 2001-12-15
  • 打赏
  • 举报
回复
用datediff 取得两个时间之间的年份即可
cctcj 2001-12-15
  • 打赏
  • 举报
回复
用gread(名字好像寫錯了,但就是那個了)型数据窗口,建四个计算列分别计算个年龄段的人数和,
再group by 职称.我想可以了吧.
tea78 2001-12-15
  • 打赏
  • 举报
回复
我以前做的时候,是用的交叉报表,因为交叉报表的表头是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);

INSERT INTO title_nl
( "titlebm",


"n61",
"n56_60",
"n51_55",
"n46_50",
"n41_45",
"n36_40",
"n31_35",
"n30"
)
values (:bm,
:nl1,
:nl2,
:nl3,
:nl4,
:nl5,
:nl6,
:nl7,
:nl8) ;
next
dw_1.retrieve()
虽然方法有点笨,但是可以实现结果。不过速度有点慢,有什么好的方法别忘了告诉我一声呀!
smartdraw 2001-12-15
  • 打赏
  • 举报
回复
■■同意yiyu(议余重出江湖) ■■
yiyu 2001-12-15
  • 打赏
  • 举报
回复
我们在做这样报表时都是通过代码实现的。用外部数据窗口就行了!!!

把代码放在一个统计按钮里去。。就一切搞定!别想太多了!
jimsuker 2001-12-15
  • 打赏
  • 举报
回复
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(+)
liq2003 2001-12-14
  • 打赏
  • 举报
回复
使用2 个数据窗口对象,一个按职称分组检索出各职称人数年龄,另一个可为外部数据源,
然后将各年龄段人数插入外部数据源数据窗口对象
m_cen 2001-12-14
  • 打赏
  • 举报
回复
仅为算法,非代码:
用 select 职称, round(( year(today) - year(出生日期))/10), ...
from XXX
where XXX...
创建datawindow,CrossTab类型的;再.....
明白?
goalitaly 2001-12-14
  • 打赏
  • 举报
回复
俺的方法
用union
建一个视图
然后,用视图为数据源建数据窗口!!


goalitaly 2001-12-14
  • 打赏
  • 举报
回复
俺的方法
用union
tjm1 2001-12-14
  • 打赏
  • 举报
回复
我太菜了呀
tjm1 2001-12-14
  • 打赏
  • 举报
回复
想的我头发都白了
goalitaly 2001-12-14
  • 打赏
  • 举报
回复
呵呵!!,不是很简单吗?
killerdanny 2001-12-14
  • 打赏
  • 举报
回复
你好好想想!
iamxia 2001-12-14
  • 打赏
  • 举报
回复
~~

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧