我想從給定日期的最後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