Solved

cumulative options in SQL query with Count function

Posted on 2004-07-30
1
1,223 Views
Last Modified: 2012-06-21
I like to create one query which will produce cumulative result also

my query

select substring(access_time_, 0, 11) "Date", count(*)"Total Downloads"
from tab1  where iface_type='web_server' and access_time_ > 
'2004-07-14 00:00:00.000' and access_time < '2004-07-29 23:59:59.999'and msisdn
not in (select number from excluded)
group by substring(access_time, 0, 11) order by  substring(access_time, 0, 11) asc

Above query will display following :

2004-07-20          2      
2004-07-27         6      

Now I would like to add cumulative result also : example
Date                    total          cumulative
2004-07-20          2                2
2004-07-27         6                8

is this possiable

Arvind
0
Comment
Question by:arvind
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 50 total points
ID: 11674456
select a.[date],a.[Total downloads],sum(b.[total downloads]) as cum
from (
select substring(access_time_, 0, 11) "Date", count(*)"Total Downloads"
from tab1  where iface_type='web_server' and access_time_ >
'2004-07-14 00:00:00.000' and access_time < '2004-07-29 23:59:59.999'and msisdn
not in (select number from excluded)
group by substring(access_time, 0, 11))
as A
Inner Join
 (
select substring(access_time_, 0, 11) "Date", count(*)"Total Downloads"
from tab1  where iface_type='web_server' and access_time_ >
'2004-07-14 00:00:00.000' and access_time < '2004-07-29 23:59:59.999'and msisdn
not in (select number from excluded)
group by substring(access_time, 0, 11))
as B
on A.[Date] >= b.[Date]
group by a.[date],a.[Total downloads]
 order by  A.[date] asc
0

Featured Post

Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

626 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question