Oracle水厂收费系统练习拓展

title: Oracle水厂收费系统练习拓展
date: 2018-1-28 22:05:23
categories: Oracle
tags: Oracle


xl_echo编辑整理,欢迎转载,转载请声明文章来源。更多案例、资料请联系QQ:1280023003

Oracle水厂收费系统练习拓展

-- 统计某日的收费,按区域分组汇总
select (select name from t_area where id = t.areaid) 区域, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account t 
where to_char(t.feedate, 'yyyy-mm-dd')='2012-05-14' group by t.areaid;
-- 注意:以上语句中areaid,如果在没有分组的情况下,不能直接跟sum函数拼接查询


-- 统计某收费员某日的收费,按区域分组汇总
select (select name from t_area where id = ac.areaid) 区域, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account ac 
where to_char(ac.feedate, 'yyyy-mm-dd') = '2012-05-14' and ac.feeuserid = 2 group by ac.areaid;

-- 统计某年某月的收费记录,按区域分组汇总
select (select name from t_area where id = ac.areaid) 区域, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account ac 
where to_char(ac.feedate, 'yyyy-mm') = '2012-05' group by ac.areaid;

select (select name from t_area where id = ac.areaid) 区域, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account ac 
where to_char(ac.meterdate, 'yyyy-mm-dd') = '2018-01-26' group by ac.areaid;
select to_char(ac.meterdate, 'yyyy-mm-dd') from t_account ac

-- 统计某收费员某年某月的收费记录,按区域分组汇总
select (select name from t_area where id = ac.areaid) 区域, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account ac 
where to_char(ac.feedate, 'yyyy-mm') = '2012-05' and ac.feeuserid = 2 group by ac.areaid;

-- 统计某年收费情况,按区域分组汇总
select (select name from t_area where id = ac.areaid) 区域, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account ac 
where to_char(ac.feedate, 'yyyy') = '2012' group by ac.areaid;

-- 统计某年收费情况,按月份分组汇总
select ac.month 月份, sum(usernum)/1000 用水量, sum(money) 金额 
from t_account ac 
where to_char(ac.feedate, 'yyyy') = '2013' group by ac.month order by ac.month;

-- 统计某年收费情况,按月份分组汇总
select  '用水量'统计项,
sum(case when ac.month = '01' then usernum end) 一月,
sum(case when ac.month = '02' then usernum end) 二月,
sum(case when ac.month = '03' then usernum end) 三月,
sum(case when ac.month = '04' then usernum end) 四月,
sum(case when ac.month = '05' then usernum end) 五月,
sum(case when ac.month = '06' then usernum end) 六月,
sum(case when ac.month = '07' then usernum end) 七月,
sum(case when ac.month = '08' then usernum end) 八月,
sum(case when ac.month = '09' then usernum end) 九月,
sum(case when ac.month = '10' then usernum end) 十月,
sum(case when ac.month = '11' then usernum end) 十一月,
sum(case when ac.month = '12' then usernum end) 十二月
from t_account ac where to_char(ac.feedate, 'yyyy') = '2013'
union all
select  '金额'统计项,
sum(case when ac.month = '01' then money end) 一月,
sum(case when ac.month = '02' then money end) 二月,
sum(case when ac.month = '03' then money end) 三月,
sum(case when ac.month = '04' then money end) 四月,
sum(case when ac.month = '05' then money end) 五月,
sum(case when ac.month = '06' then money end) 六月,
sum(case when ac.month = '07' then money end) 七月,
sum(case when ac.month = '08' then money end) 八月,
sum(case when ac.month = '09' then money end) 九月,
sum(case when ac.month = '10' then money end) 十月,
sum(case when ac.month = '11' then money end) 十一月,
sum(case when ac.month = '12' then money end) 十二月
from t_account ac where to_char(ac.feedate, 'yyyy') = '2013';

-- 根据业主类型分别统计每种居民的用水量(整数,四舍五入)及收费金额 ,如果该类型在台账表中无数据也需要列出值为0的记录
select ow.name, nvl(round(sum(usernum)/1000), 0) 用水量, nvl(sum(money),0) 金额 
from t_ownertype ow, t_account ac 
where ow.id=ac.ownertypeid(+)
group by ow.name;

-- 统计每个区域的业主户数,并列出合计
select ar.name 区域, count(ow.id) 业主户数
from t_area ar, t_owners ow, t_address ad
where ar.id=ad.areaid and ow.addressid=ad.id
group by ar.name
union all
select '统计', count(*) from t_owners;

-- 统计每个区域的业主户数,如果该区域没有业主户数也要列出0
select ar.name 区域,count(owad.id) 业主户数
from T_AREA ar ,
(
select ow.id,ow.name,ad.areaid from T_OWNERS ow,T_ADDRESS ad where ow.addressid=ad.id
)
owad 
where ar.id=owad.areaid(+)
group by ar.name
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
《新源水厂管理收费系统 网络版》是根据水厂公司的实际运营情况编写的一套完善的收费系统。本系统包括了七大组成部分:用户管理、开户管理、抄表管理、减免管理、预存管理、收费管理、数据报表。本系统功能齐全、操作方便经过长期收费使用,系统运行稳定可靠,其特点如下: 1、一户一表、一表多户(总表、单户同时管理,区别收费)。 2、批量建档,自动生成户号,建档错误自动报警。 3、多种用户卡片打印方式,增加用户按抄表人员自动或自定义排序,方便抄表人员抄表。 4、批量抄表,抄表起度、止度不正确自动报警,支持抄表机抄表、支持水损计算。 5、实用度数收取和基本度数收取两种收费模式,两种收费模式可以随时转换。 6、可灵活设置多种气价类型和附加费,不同的气价类型可以设置不同的基本方、不同的气价类型可以设置不同的附加费,附加费计算方式有二种:按用量和按固定金额计算。 7、可以开启和关闭收款四舍五入功能,方便找零。 8、可以开启和关闭用户的个人帐户结余(开启后上期找零结余自动累加到下期收款中)。 9、预存收费功能,预存收款自动扣款、预存收款不足自动提示,预存扣款明细可以随时查询。 10、完善和统一的发票管理、发票统计、发票作废、补打发票。 11、支持用户减免管理,可以实施多种条件对用户实行全额减免或部分减免,永久减免或按次数减免。 12、支持批量收费和发票连打功能。 13、支持按固定金额或按利率结算的滞纳金管理功能。 14、支持阶梯水价功能,阶梯水价和固定水价两种收费方便,可以随时转换;并且阶梯水价的各个阶梯段可以自定义设置,并且可以设置无限个阶梯段。 15、支持磁卡收费功能。 16、支持正式发票管理功能。 17、支持发票套打功能。 18、支持操作人员权限功能。 19、支持日志管理功能。 20、支持自动备份数据库功能。 21、支持多套界面皮肤功能。 22、功能强大的财会管理和统计查询系统。 23、 支持换表管理。 24、支持固定抄表。 25、支持用户开户管理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xlecho

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值