更新财务报表2
2015-09-08 20:08
344 查看
-- 查询月服务天数不等于 数据库中存的月服务天数
SELECT b.day1,a.days_of_month from erp_work_day_opt_info_copy a, (select count(DISTINCT service_day) as day1 , order_id from erp_work_day_opt_info_copy where service_day >= '2015-08-01' and service_day <= '2015-08-01' and order_state =4 GROUP BY order_id )b where a.order_id = b.order_id and service_day = '2015-08-01' and order_state =4 and b.day1 != a.days_of_month
-- 查询更改前 和更改后的 月服务天数数据 select a.order_id,a.days_of_month,ac.days_of_month from erp_work_day_opt_info_copy ac,erp_work_day_opt_info a where ac.id = a.id and ac.order_state = 4 and a.days_of_month != ac.days_of_month and ac.service_day = '2015-08-06'
-- 更新 月服务天数 UPDATE erp_work_day_opt_info_copy a set a.days_of_month =( SELECT day1 from ( select count(DISTINCT service_day) as day1,order_id from erp_work_day_opt_info_copy where service_day >= '2015-08-01' and service_day <= '2015-08-31' and order_state =4 GROUP BY order_id ) b where a.order_id =b.order_id ) where service_day = '2015-08-31' and order_state =4
-- 3号投放的,月服务天数 不等于1的错误数据 SELECT days_of_month from erp_work_day_opt_info where order_id in(1116111412293638431, 111611201503260001, 161410111705426422, 16150523100003515937, 16150624114818157101, 1620150406140658405541, 1620150422183741941759)and service_day = '2015-08-03' and order_state =4 ;
-- 查询8月1号 日客单价不等于 月服务金额 SELECT * FROM erp_work_day_opt_info_copy a, erp_work_order b WHERE service_day like '%2015-08-01%' AND a.order_id = b.order_id and a.customer_price_per_day != a.money_of_month and a.order_state = 4
-- 查询
SELECT a .order_id from erp_work_order a ,(SELECT order_id, count(DISTINCT service_day) FROM erp_work_day_opt_info_copy WHERE service_day LIKE '2015-08%' AND rest_service_days <= 0 AND order_state = 4 GROUP BY order_id HAVING count(DISTINCT service_day) > 1) b where a.order_id =b.order_id and a.inner_flag =0
-- 查询 剩余天数小于等于0的并且大于1天的 SELECT * from erp_work_day_opt_info_copy where order_id in (SELECT order_id FROM erp_work_day_opt_info_copy WHERE service_day LIKE '2015-08%' AND rest_service_days <= 0 AND order_state = 4 GROUP BY order_id HAVING count(DISTINCT service_day) > 1 )
and service_day LIKE '2015-08%' AND rest_service_days <= 0 ORDER BY order_id desc
SELECT b.day1,a.days_of_month from erp_work_day_opt_info_copy a, (select count(DISTINCT service_day) as day1 , order_id from erp_work_day_opt_info_copy where service_day >= '2015-08-01' and service_day <= '2015-08-01' and order_state =4 GROUP BY order_id )b where a.order_id = b.order_id and service_day = '2015-08-01' and order_state =4 and b.day1 != a.days_of_month
-- 查询更改前 和更改后的 月服务天数数据 select a.order_id,a.days_of_month,ac.days_of_month from erp_work_day_opt_info_copy ac,erp_work_day_opt_info a where ac.id = a.id and ac.order_state = 4 and a.days_of_month != ac.days_of_month and ac.service_day = '2015-08-06'
-- 更新 月服务天数 UPDATE erp_work_day_opt_info_copy a set a.days_of_month =( SELECT day1 from ( select count(DISTINCT service_day) as day1,order_id from erp_work_day_opt_info_copy where service_day >= '2015-08-01' and service_day <= '2015-08-31' and order_state =4 GROUP BY order_id ) b where a.order_id =b.order_id ) where service_day = '2015-08-31' and order_state =4
-- 3号投放的,月服务天数 不等于1的错误数据 SELECT days_of_month from erp_work_day_opt_info where order_id in(1116111412293638431, 111611201503260001, 161410111705426422, 16150523100003515937, 16150624114818157101, 1620150406140658405541, 1620150422183741941759)and service_day = '2015-08-03' and order_state =4 ;
-- 查询8月1号 日客单价不等于 月服务金额 SELECT * FROM erp_work_day_opt_info_copy a, erp_work_order b WHERE service_day like '%2015-08-01%' AND a.order_id = b.order_id and a.customer_price_per_day != a.money_of_month and a.order_state = 4
-- 查询
SELECT a .order_id from erp_work_order a ,(SELECT order_id, count(DISTINCT service_day) FROM erp_work_day_opt_info_copy WHERE service_day LIKE '2015-08%' AND rest_service_days <= 0 AND order_state = 4 GROUP BY order_id HAVING count(DISTINCT service_day) > 1) b where a.order_id =b.order_id and a.inner_flag =0
-- 查询 剩余天数小于等于0的并且大于1天的 SELECT * from erp_work_day_opt_info_copy where order_id in (SELECT order_id FROM erp_work_day_opt_info_copy WHERE service_day LIKE '2015-08%' AND rest_service_days <= 0 AND order_state = 4 GROUP BY order_id HAVING count(DISTINCT service_day) > 1 )
and service_day LIKE '2015-08%' AND rest_service_days <= 0 ORDER BY order_id desc
相关文章推荐
- STL之map容器的详解
- 让网站网址实现百度秒收录
- 通过迁移的方式解决Active Directory服务器问题之1-迁移前的准备工作
- python 生成器
- hadoop2.x的HA简介
- struct和typedef struct
- hdu 2120 Ice_cream's world I
- 1023. 组个最小数 (20)
- struct和typedef struct
- qt使用
- mybatis + postgresql 遇到的问题
- 初试WebSocket构建聊天程序
- 如何让优秀文章排名大于原创文章
- Unable to execute dex: method ID not in [0, 0xffff]: 65536
- poj 3190 经典贪心(区间图:色数=团数)
- 数据库Sharding的基本思想和切分策略
- Android 笔记7
- iOS UIRefreshControl的使用 示例
- 使用Python做科学计算初探
- net_device 结构