2016-05-26 18 views
-1

昨年の純売上高も月ごとにどのように得ることができますか?
私は今月の売上情報を関連する増減率で報告しようとしています。MySQL今年の売上高を月別、前年度別に検索する

select date_format(sdate,'%M-%Y') as sdate,  
    sum(netsales) as 'netsales', 
    from repsoft.daily 
    where scode=1234 and year(sdate)=year('2016-06-01') 
    group by month(sdate) 
    order by month(sdate); 
+0

テーブルサンプルや試行結果など詳細を追加できますか? – DenisGL

答えて

0

なぜあなたも年単位でグループ化しませんか?

select date_format(sdate,'%M-%Y') as sdate,  
    sum(netsales) as 'netsales', 
    from repsoft.daily 
    where scode=1234 and year(sdate)=year('2016-06-01') 
    group by year(sdate), month(sdate) 
    order by year(sdate), month(sdate);