【发布时间】:2014-02-22 09:47:32
【问题描述】:
这就是我想要达到的目标:
我有 2 个 sql 表: 交易和支付计划 下面是2个表的结构:
交易
uid | plan | date | payid | status
------------------------------------
12 | 3 | 1388534400 | 334 | 1
699 | 4 | 1388214400 | 335 | 1
支付计划:
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 月开始的每个月的价格总和 例如:
1 月 13 日 | 9.99
2 月 13 日 | 29.99 等等
【问题讨论】:
-
您使用的是哪个 rdbms?另外,请提供
SHOW CREATE TABLE transactions;和SHOW CREATE TABLE payplans;或DESC transactions;和DESC payplans;
标签: mysql sql unix-timestamp