Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mysql cumulative total
Message
 
 
To
18/03/2011 07:13:08
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01504071
Message ID:
01504072
Views:
40
I'm confused, is it mysql or MS SQL Server?

>
>I'm trying to get a monthly cumulative total.
>
>I have sql that give me that but I need to refine it to only give me and in warranty cumulative total ie two years.
>
>So the cumulative total is a two year snapshot.
>
>My sql query is
>
>select pop AS yearmonth,
>   ifnull((select sum(s2.stock_count) AS sum_stock_count
>  from c_stock_month_model2 s2
>  where  s2.pop <= t.pop ),0) AS cum_month_stock_count
>  from c_stock_month_model t
>  order by pop;
>
>
>I tried adding a condition in the subquery
>
>
>select pop AS yearmonth,
>   ifnull((select sum(s2.stock_count) AS sum_stock_count
>  from c_stock_month_model2 s2
>  where  s2.pop <= t.pop
>  and datediff(s2.pop,t.pop)<810),0) AS cum_month_stock_count
>  from c_stock_month_model t
>  order by pop;
>
>
>but it still includes all the data.
>
>Any thoughts on a way to get this
>
>Thanks
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform