select [wrong_type],[reason],count(*) as 数量 from ( SELECT [id] ,[check_date] ,[checker] ,[inspected_person] ,[secondary_rework] ,[type] ,[project] ,[project_name] ,[NID] ,[wrong_type] ,[reason] ,[wrong_description] ,[complaint_status] ,[date] ,[create_time] FROM [DV_report].[dbo].[miss] where date>='${start}' and date<='${end}' and complaint_status='申诉后' and wrong_type not in ('无','建议') and inspected_person not in('DL001','DL002') UNION SELECT [id] ,[check_date] ,[checker] ,[secondary_rework] as [inspected_person] ,[inspected_person] as [secondary_rework] ,[type] ,[project] ,[project_name] ,[NID] ,[wrong_type] ,[reason] ,[wrong_description] ,[complaint_status] ,[date] ,[create_time] FROM [DV_report].[dbo].[miss] where date>='${start}' and date<='${end}' and complaint_status='申诉后' and wrong_type = '网络问题' and [reason] = '状态错误' and [inspected_person] is not null and [inspected_person] !='' and inspected_person not in('DL001','DL002') )as a group by [wrong_type],[reason] order by [wrong_type],[reason] 帮我将这段代码转换为postgre格式语言
时间: 2023-08-18 16:11:00 浏览: 97
SELECT "wrong_type", "reason", count(*) as 数量
FROM (
SELECT "id"
,"check_date"
,"checker"
,"inspected_person"
,"secondary_rework"
,"type"
,"project"
,"project_name"
,"NID"
,"wrong_type"
,"reason"
,"wrong_description"
,"complaint_status"
,"date"
,"create_time"
FROM "DV_report"."dbo"."miss"
WHERE "date">='${start}'
AND "date"<='${end}'
AND "complaint_status"='申诉后'
AND "wrong_type" NOT IN ('无','建议')
AND "inspected_person" NOT IN('DL001','DL002')
UNION
SELECT "id"
,"check_date"
,"checker"
,"secondary_rework" AS "inspected_person"
,"inspected_person" AS "secondary_rework"
,"type"
,"project"
,"project_name"
,"NID"
,"wrong_type"
,"reason"
,"wrong_description"
,"complaint_status"
,"date"
,"create_time"
FROM "DV_report"."dbo"."miss"
WHERE "date">='${start}'
AND "date"<='${end}'
AND "complaint_status"='申诉后'
AND "wrong_type" = '网络问题'
AND "reason" = '状态错误'
AND "inspected_person" IS NOT NULL
AND "inspected_person" !=''
AND inspected_person NOT IN('DL001','DL002')
) AS a
GROUP BY "wrong_type","reason"
ORDER BY "wrong_type","reason"
阅读全文