Commit babe3211 by 仲光辉

feat: add SQL.

parent 82fbb8a3
# # 2022.05.25
# # 2022.05.25
......@@ -5200,6 +5200,11 @@
### 线上数据已经执行 执行时间: 2022.10.31 17:45
alter table bill
add overdue_charge_way tinyint(1) default 0 null comment '滞纳金逾期收费方式 0:不收取滞纳金 1:滞纳金仅计算不收取 2:滞纳金计入账单收取 default: 0';
......
### 更新SQL
### 更新SQL
UPDATE bill AS b
SET b.is_delete=1,
b.remark='20221109重复数据删除'
WHERE b.is_delete = 0
AND b.uuid IN
(SELECT DISTINCT bi.bill_uuid
FROM bill_item AS bi
INNER JOIN admin AS a ON a.is_delete = 0 AND a.uuid = bi.create_uuid
WHERE bi.is_delete = 0
AND bi.charging_start_date = '2022-10-01'
AND bi.charging_end_date = '2022-10-31'
AND bi.fee_type = '电费'
AND bi.create_uuid = '86608101df46418eac0512250f27ddd0'
# AND bi.create_uuid='e094ae5090224ec09f0f7d549c20c845'
AND bi.contract_code IN (SELECT DISTINCT contract_code
FROM bill_item
WHERE charging_start_date = '2022-10-01'
AND charging_end_date = '2022-10-31'
AND is_delete = 0
AND contract_code not like '%测试%'
AND fee_type = '电费'
GROUP BY contract_uuid, fee_type, amount
HAVING COUNT(contract_uuid) > 1)
ORDER BY bi.amount);
UPDATE bill_item AS bi
SET bi.is_delete=1,
bi.bill_item_remark='20221109重复数据删除'
WHERE bi.is_delete = 0
AND bi.bill_uuid IN
(SELECT DISTINCT b.uuid
FROM bill AS b
WHERE b.is_delete = 1
AND b.charging_start_date = '2022-10-01'
AND b.charging_end_date = '2022-10-31'
AND b.create_uuid = '86608101df46418eac0512250f27ddd0'
AND b.remark = '20221109重复数据删除');
### 查询 SQL
SELECT COUNT(contract_uuid), contract_uuid, contract_code, fee_type, amount
FROM bill_item
WHERE charging_start_date = '2022-10-01'
AND charging_end_date = '2022-10-31'
AND is_delete = 0
AND contract_code not like '%测试%'
AND fee_type = '电费'
GROUP BY contract_uuid, fee_type, amount
HAVING COUNT(contract_uuid) > 1;
SELECT bi.uuid,
bi.contract_code,
bi.amount,
bi.charging_start_date,
bi.charging_end_date,
bi.create_time,
bi.create_uuid,
bi.is_delete,
a.name
FROM bill_item AS bi
INNER JOIN admin AS a ON a.is_delete = 0 AND a.uuid = bi.create_uuid
WHERE bi.is_delete = 0
AND bi.charging_start_date = '2022-10-01'
AND bi.charging_end_date = '2022-10-31'
AND bi.fee_type = '电费'
AND bi.create_uuid='86608101df46418eac0512250f27ddd0'
# AND bi.create_uuid='e094ae5090224ec09f0f7d549c20c845'
AND bi.contract_code IN (SELECT DISTINCT contract_code
FROM bill_item
WHERE charging_start_date = '2022-10-01'
AND charging_end_date = '2022-10-31'
AND is_delete = 0
AND contract_code not like '%测试%'
AND fee_type = '电费'
GROUP BY contract_uuid, fee_type, amount
HAVING COUNT(contract_uuid) > 1)
ORDER BY bi.amount;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment