這裏就是我嘗試才達到:排序SQL結果按月與UNIX
我有2個SQL表: 交易和payplans 波紋管2代表的結構:
交易
uid | plan | date | payid | status
------------------------------------
12 | 3 | 1388534400 | 334 | 1
699 | 4 | 1388214400 | 335 | 1
payplans:
plan | plan_price
-------------------
3 | 9.99
4 | 19.99
與此查詢:
SELECT SUM(plan_price)
FROM transations AS t
INNER JOIN payplans AS p
ON t.plan = p.plan
WHERE t.status = '1'
我能計算所有「plan_price」行的總和, 但我想有價格總和每月啓動2013年1月 例如:
揚-13 | 9.99
feb-13 | 29.99 等
您正在使用哪種rdbms?此外,請提供'SHOW CREATE TABLE交易;'和'SHOW CREATE TABLE payplans;'或'DESC transactions;'和DESC payplans;' – Alexander
Im使用MySql rdbms – VDonchev