0

Customers、BillingDate、Consumption の 3 つの列を持つテーブルがあります。

CITY - PARKS/6TH AVE BMX PARK   2013-04-29 00:00:00.000 0
CITY - PARKS/6TH AVE BMX PARK   2013-04-29 00:00:00.000 30
CITY - PARKS/6TH AVE BMX PARK   2013-05-30 00:00:00.000 0
CITY - PARKS/6TH AVE BMX PARK   2013-05-30 00:00:00.000 19500
CITY - PARKS/6TH AVE BMX PARK   2013-06-28 00:00:00.000 0
CITY - PARKS/6TH AVE BMX PARK   2013-06-28 00:00:00.000 42100
CITY - FIRE STATION #3  2012-11-27 00:00:00.000 0
CITY - FIRE STATION #3  2012-11-27 00:00:00.000 8900
CITY - FIRE STATION #3  2012-12-27 00:00:00.000 0
CITY - FIRE STATION #3  2012-12-27 00:00:00.000 7900
CITY - FIRE STATION #3  2013-01-28 00:00:00.000 0
CITY - FIRE STATION #3  2013-01-28 00:00:00.000 3090
CITY - FIRE STATION #3  2013-01-28 00:00:00.000 7210
CITY - FIRE STATION #3  2013-02-28 00:00:00.000 0
CITY - FIRE STATION #3  2013-02-28 00:00:00.000 10100
CITY - FIRE STATION #3  2013-03-29 00:00:00.000 0
CITY - FIRE STATION #3  2013-03-29 00:00:00.000 6700
CITY - FIRE STATION #3  2013-04-29 00:00:00.000 0
CITY - FIRE STATION #3  2013-04-29 00:00:00.000 9100
CITY - FIRE STATION #3  2013-05-30 00:00:00.000 0
CITY - FIRE STATION #3  2013-05-30 00:00:00.000 11100
CITY - FIRE STATION #3  2013-06-28 00:00:00.000 0
CITY - FIRE STATION #3  2013-06-28 00:00:00.000 12700
CITY - FIRE STATION #3  2012-07-27 00:00:00.000 0
CITY - FIRE STATION #3  2012-08-27 00:00:00.000 0
CITY - FIRE STATION #3  2012-08-27 00:00:00.000 1630
CITY - FIRE STATION #3  2012-09-28 00:00:00.000 0

同じ顧客に対して同じ BillingDate があるため、一致する BillingDate に基づいて消費を合計したいと考えています。これにより、次のようになります。

CITY - PARKS/6TH AVE BMX PARK   2013-04-29 00:00:00.000 30
CITY - PARKS/6TH AVE BMX PARK   2013-05-30 00:00:00.000 19500
CITY - PARKS/6TH AVE BMX PARK   2013-06-28 00:00:00.000 42100
CITY - FIRE STATION #3  2012-11-27 00:00:00.000 8900

等々....

同様の質問を投稿しましたが、探しているものを実際に取得できませんでした。SQLの専門家に感謝します。

4

2 に答える 2