Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Mysql cumulative total
Message
De
18/03/2011 07:13:08
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Mysql cumulative total
Divers
Thread ID:
01504071
Message ID:
01504071
Vues:
112
Hi

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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform