如何计算不同文章

时间:2017-08-03 13:38:32

标签: sql

我有一个包含4列的表:

Date   Article  Customer   Turnover

我希望每6个月为每篇文章计算每个客户的营业额AVG

From January to June ==> Turnover 1 of customer 1 for article 1
From Febrary to July ==> Turnover 2 customer 1 for article 1
From March to August ==> Turnover 3 customer 1 for article 1
From April to September ==> Turnover 4 customer 1 for article 1
From May to Obtober ==> Turnover 5 customer 1 for article 1
From June to November ==> Turnover 6 customer 1 for article 1
From July to December ==> Turnover 7 customer 1 for article 1

然后我按照每个6个月的所有营业额的sum进行划分,如上面的例子所示,但是对所有客户和所有文章都是。

我的数据如下:

      Date        Article  IdCustomer Turnover

    "2016-01-04"    "ATSU"  17182   7146
    "2016-01-05"    "ATSU"  17182   3079    
    "2016-02-06"    "ATSU"  17182   4012
    "2016-02-22"    "MFC"   17182   1398
    "2016-03-04"    "ATSU"  17182   4504
    "2016-04-02"    "ATSU"  17182   5214878
    "2016-05-25"    "ATSU"  17182   2365147
    "2016-06-10"    "ATSU"  17182   2598741
    "2016-07-18"    "ATSU"  17182   1845425
    "2016-08-04"    "ATSU"  17182   845350
    "2016-09-12"    "ATSU"  17182   87418    
    "2016-10-26"    "ATSU"  17182   4012
    "2016-11-25"    "MFC"   17182   1398
    "2016-12-21"    "ATSU"  17182   4504

我有几个客户的相同例子。

问题是我无法找到一个解决方案来汇总每个cusomerarticle个月的营业额。

有人请帮助我并给我一个解决方案如何解决这个问题?

谢谢;

0 个答案:

没有答案