Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

MS SQL: getting Sum over last 14 days per group

$
0
0

Hello,

first - i'm not very good in SQL - and with google i could figure out a solution on this...

i have the following script:

SQL
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
withusrShowAuftragsbestandCTEas(selectconvert(date,Convert(varchar,Monat)+'-'+Convert(varchar,Tag)+'-'+Convert(varchar,Jahr))asDuedate,Netto,ZielgebietfromusrShowAuftragsbestand)selectDuedate,round(SUM(Netto),2)asNettoSumme,ZielgebietfromusrShowAuftragsbestandCTEWHEREDATEDIFF(DAY,Duedate,GETDATE())<14groupbyDuedate,ZielgebietorderbyDuedatedesc,Zielgebiet
which gives me a list of NettoSumme for each day per group (see printscren).


but now i dont know how to go further and get the sum from one day / date - over all groups (Zielgebiete).
How can i get this sum over the groups?

thanks for any help

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>