SELECT sgs.id, sgs.supply_goods_id, sgs.standard_send_price FROM g_supply_goods_sell sgs INNER JOIN g_supply_goods_area sga ON sga.supply_sell_id = sgs.id WHERE sgs.sell_state = 'ENABLED' AND sga.tenant_id = 10 AND sga.area_no IN ( '510000', '510100', '510106', '510106002000' ) ORDER BY sgs.sell_type 对supply_goods_id去重
时间: 2023-11-14 22:05:02 浏览: 77
你的问题是如何对 supply_goods_id 进行去重操作,可以使用以下 SQL 语句:
```
SELECT DISTINCT supply_goods_id
FROM (
SELECT sgs.id, sgs.supply_goods_id, sgs.standard_send_price
FROM g_supply_goods_sell sgs
INNER JOIN g_supply_goods_area sga ON sga.supply_sell_id = sgs.id
WHERE sgs.sell_state = 'ENABLED' AND sga.tenant_id = 10 AND sga.area_no IN ( '510000', '510100', '510106', '510106002000' )
ORDER BY sgs.sell_type
) AS t;
```
这个 SQL 语句将原始查询作为子查询,然后在外层使用 DISTINCT 关键字对 supply_goods_id 进行去重操作。
阅读全文