0

所需表应合并原始表中的两行,并将两行中的描述附加到单个所需表中

原始表

id  quantity    item_number description unit_price  Total   returns
1   100         MISC SALES  Misc Sales  0.3         30      ABC
2   NULL        NULL        XXXXXX      NULL        NULL    ABC
3   200         MISC SALES  Misc Sales  0.45        90      ABC
4   NULL        NULL        YYYYYY      NULL        NULL    ABC

所需表

id  quantity    item_number description         unit_price  Total   returns
1   100         MISC SALES  Misc Sales XXXXXX   0.3         30      ABC
2   200         MISC SALES  Misc Sales YYYYYY   0.45        90      ABC
4

1 回答 1

1
select round(id/2),quantity,,item_number,GROUP_CONCAT(" " ,description) , unit_price,Total, returns 
from (

 select id,quantity,item_number, description, unit_price,Total, returns from table1 where id%2=1 

UNION

 select id-1,quantity,item_number, description ,unit_price,Total, returns from table1 where id%2=0 
) as temp group by id;
于 2013-09-02T10:52:38.377 回答