表中记录了手机欠费的情况,有三个字段
mobile_no(手机号码),date(欠费年月),money(当月欠费金额)
如:
13302710113 200307 122
现在要统计连续三个月都欠费的手机号码,以及欠费总金额
能直接利用Sql语句得到上面的结果吗?
mobile_no(手机号码),date(欠费年月),money(当月欠费金额)
如:
13302710113 200307 122
现在要统计连续三个月都欠费的手机号码,以及欠费总金额
能直接利用Sql语句得到上面的结果吗?
解决方案 »
- 为什么我的delphi6里怎么没有webservice页?如何安装?
- 有没有高手做过这样的listview,能实现吗??欢迎高手进来!!!!
- 各位高手帮帮忙,网上哪里有能实现这个功能的DELPHI编程代码或各位有什么设计方法啊???
- 请教请教一个加密反加密问题(这里先谢)
- 还是memo写入文本的问题,大家帮忙
- 我用了一个Twebrowser组件,但是里面的网页登陆后,弹开的网页(调用ie)却不能正确得到登陆名(因为没有得到Cookie),请问如何才能让we
- SQL语句出错
- 根据日期值怎么得到是星期几?
- ◎◎◎可有提供打印功能的 DBGrid 控件???
- 如何得到dbgrideh的页脚的统计值
- 我是一个DELPHI的爱好者,强烈推荐大家到kingron.delphibbs.com上找找。
- 俺给各位磕头了!!!只要能解决一个问题。。。。online waiting...
select mobile_no
from t
where count(*)>=3
group by mobile_no
;select mobile_no
from t
where date='200307' and mobile_no in (select mobile_no
from t
where date='200306' and mobile_no in select mobile_no
from t
where date='200305' and mobile_no in))
;
from t
where date='200307' and mobile_no in (select mobile_no
from t
where date='200306' and mobile_no in (select mobile_no
from t
where date='200305' and mobile_no in))
;
from t
where date='200307' and mobile_no in (select mobile_no
from t
where date='200306' and mobile_no in (select mobile_no
from t
where date='200305'))
;
select
a.mobile_no as 手机号码,(a.money+b.money+c.money) as 欠费总额
from
table as a,table as b,table as c
where
a.mobile_no=b.mobile_no and a.mobile_no=c.mobile_no
and a.date='200307',b.date='200306',c.date='200305'
select
a.mobile_no as 手机号码,(a.money+b.money+c.money) as 欠费总额
from
table as a,table as b,table as c
where
a.mobile_no=b.mobile_no and a.mobile_no=c.mobile_no
and a.date='200307' and b.date='200306' and c.date='200305'
提点建议:
把数据库按主关键字:手几号码,次关键字:前费年月升序排序
用存储过程或编写Delphi程序从数据开头逐条判断
用三个变量,一个记录手机号码num,一个记录欠费年月date,欠费的月数n
按如下步骤完成:
while not 表单.eof do
begin
if num=手机号码 then
if n<3
begin
if date-欠费年月=1个月 then
begin
n=n+1
if n=3 then
记录该手机号//再用一个临时表单
end
end
else
begin
n=1
num=手机号
date=欠费年月
end
到下一条纪录
end
我已经编写了一段程序,完成了上述功能
非常感谢大家对我的热情帮助!