group by-删除和求和sql中的重复行,有人能为我的查询提供见解吗?
发布时间:2022-04-07 00:37:02 487
相关标签: # 数据库
我的问题是这样的
SELECT
A."name" AS so_name,
CASE WHEN COUNT(*) OVER (PARTITION BY A."name")> 1
THEN CONCAT('duplicate')
ELSE CONCAT('is unique')
END AS tags,
e.total_qty AS sc_qty,
(SELECT DISTINCT ( COALESCE(e.amount_total) * COALESCE (ai.base_currency_rate, 1))
FROM account_invoice ai JOIN invoice_sale_rel isr ON isr.invoice_id = ai.ID
WHERE isr.sale_id = e.ID) AS sc_total
FROM sale_quotation A JOIN res_partner b ON b.ID = A.partner_id
JOIN sale_order e ON e.quotation_id = A.ID
LEFT JOIN res_users C ON C.ID = A.user_id
LEFT JOIN res_partner d ON d.ID = C.partner_id
WHERE A.STATE != 'cancel'
AND e.STATE != 'cancel'
AND e.is_merchant = TRUE
ORDER BY A.NAME ASC
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报