Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple query Help

Status
Not open for further replies.

sqlblind

MIS
May 27, 2011
12
GB
Hi guys

I have a data table which looks something like this:

Date Channel Actual
1 3 4545
1 1 666
1 6 5456
2 1 1511
2 1 4888
3 1 1545
4 1 643
4 2 5697
4 3 6833
5 2 5555
6 6 5668

I want to sum the actual amount up to a certain point in time, eg i want the aggregate up to the 4th

Select sum(Actual) from table where date = 4

This only gives me the value on the 4th i also want the 1st,2nd and 3rd included in the sum.

Any help would be hugely grateful..

 
Code:
Select sum(Actual) from table where date <= 4
 
Thanks, Ok forgot to mention i have other months in there to. and only want every aggregated up to a certain point of the month

So
Date Channel Actual
1/01/11 3 4545
1/01/11 1 666
1/01/11 6 5456
2/01/11 1 1511
2/01/11 1 4888
3/01/11 1 1545
4/01/11 1 643
4/01/11 2 5697
4/01/11 3 6833 -- 31784
5/01/11 2 5555
6/01/11 6 5668
1/02/11 3 2212
1/02/11 1 622
1/02/11 6 5477
2/02/11 1 1552
2/02/11 1 5659


eg month 01 up to the 4 is 31784
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top