我想从给定日期的最后1年的数据。例如:查询使用mysql从给定日期查找去年每个月的数据?
我有日期2013-06-01
,我想数据如下也是数据我是从三个表使用Group By
或别的东西
Month | Amount | Total_Data
June 2013 100 5
May 2013 80 4
- 100 5
- 100 5
July 2012 10 2
希望
我尝试下面的查询,但没有锻炼
SELECT DATE_FORMAT(rf.period, '%M %Y') as Month
, sum(p.amount * ((100-q.amount)/100)) as Amount
,count(distinct q.label_id) as Total Data
FROM table1 rf
, table2 p
, table3 q
,table4 a
where rf.period BETWEEN '2013-06-01' AND '2013-06-01'
and q.royalty_period BETWEEN '2013-06-01' AND '2013-06-01'
and a.id = q.album_id
and p.file_id = rf.id
and p.upc = a.upc
and p.local_revenue is not null
GROUP BY Month
它是如何锻炼的?你的结果是什么? – 2010-03-26 07:10:10