Mysql行和列转换

时间:2017-04-30 11:21:53

标签: mysql

我正在查询我的sql查询:

SELECT particulars.particularName as name, particulars.Date as date, SUM(particulars.Total) as Total 
FROM particulars 
WHERE particulars.Date BETWEEN '2017-04-01' AND '2017-04-30' 
    AND particulars.Branch_BranchId='1'
GROUP by particulars.particularName,particulars.Date

输出格式为:: current output

但我需要以下格式输出: Required output

1 个答案:

答案 0 :(得分:0)

您需要的是所谓的旋转。

看看这个例子(你可以在网上找到很多):

http://stratosprovatopoulos.com/web-development/mysql/pivot-a-table-in-mysql/