【发布时间】:2017-05-23 03:35:45
【问题描述】:
我有下表imagetable...
这是我的查询...
SELECT w.name as wholesaler_name,
w.outlet_id,
w.distributor_name,
w.distributor_id,
wt.name as tipe_plus,
v.target,
v.week as periode,
SUM(v.total_transaction),
v.rebate,
v.total_voucher
FROM voucher v
JOIN wholesalers w ON w.id=v.wholesaler_id
JOIN wholesaler_types wt ON w.wholesaler_type_id=wt.id
GROUP BY w.name,
w.outlet_id,
w.distributor_name,
w.distributor_id,
wt.name,
v.target,
v.week,
v.rebate,
v.total_voucher;
在periode一栏,有一个wholesaler_name有一个2,同时期(11.2017)。我想要这样,如果发生这种情况,total_transaction 列将变为SUM()。
我使用GROUP BY,但结果还是一样。
希望你能帮忙。
谢谢。
【问题讨论】: