日期:2014-05-19 浏览次数:20658 次
select distinct substr(lot_no, 1, instr(lot_no, '#')-1) as lot_no, customer, total, no from table
------解决方案--------------------
8好意思,错了,LZ不是选出不同,而是求和
select substr(lot_no, 1, instr(lot_no, '#')-1) as lot_no, customer, sum(total) ,no from table group by lot_no,no,customer
------解决方案--------------------
select substr(lot_no,1,4) as lot_no ,customer ,sum(total) ,no from 表 group by substr(lot_no,1,4),customer ,no
------解决方案--------------------
这是MySQL的
SELECT MID(lot_no,1,4), customer , SUM(total),no
FROM 表 GROUP BY MID(lot_no,1,4)
select substr(lot_no, 1, instr(lot_no, '#')-1) as lot_no, customer, sum(total) ,no from table group by substr(lot_no, 1, instr(lot_no, '#')-1) ,no ,customer