1
我需要的输出是这样的:MySQL的一个月明智的报告
Month -->| Pre_Mnth2 | Pre_Mnth1 | current_Month_ Name
Product A | 3387 | 87985 | 2338
Product B | 6386 | 67983 | 6374
Product C | 3880 | 76988 | 9378
...
所有需要的数据是唯一的单表。
列如下:
id | companycode | merchantcode| pdtname | qty | value | invdate |
任何人可以帮助我用PHP MySQL查询代码?
我当前的代码返回数据,当月仅
SELECT `pdtname`, `qty`, `value`, sum(`qty`), sum(`value`)
FROM `ist`
WHERE merchantcode = $q AND companycode = $companycode
AND MONTH(invdate) = $currentdate[mon]
GROUP BY `pdtname`
这里变量$q
和$companycode
从用户的会议上作出。
你需要每个月在结果一个单独的列? – Nikhil