Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sorting Problem with cummilative Sum

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-12-06 : 08:42:09
Saikat writes "Respected ALL,

My Sql Query is as follows--------

select Delivery_Date, delivery, delivery+coalesce((select sum(delivery) from
((select d as Delivery_Date,((del*100)/all_postnet) as delivery from
(select count(distinct postnet) as all_postnet from all_selected_planet_report) x,
(select substring(a.dt_time,1,10)as d,count(distinct a.postnet)as del from maildata a, all_selected_planet_report b, maildlvconfirmation c
where a.postnet=b.postnet and a.op_code =c.[operation code] group by substring(a.dt_time,1,10))z)) k
where k.delivery < p.delivery),0)
from
((select d as Delivery_Date,((del*100)/all_postnet) as delivery from
(select count(distinct postnet) as all_postnet from all_selected_planet_report) x,
(select substring(a.dt_time,1,10)as d,count(distinct a.postnet)as del from maildata a, all_selected_planet_report b, maildlvconfirmation c
where a.postnet=b.postnet and a.op_code =c.[operation code] group by substring(a.dt_time,1,10))z)) p
order by Delivery desc


and the output is comming as ------

Delivery_Date delivery cummultive sum

12/01/2004 10.00 21.00
12/02/2004 9.00 11.00
11/30/2004 2.00 2.00

but i want the output as follows----

Delivery_Date delivery cummultive sum

12/02/2004 9.00 21.00
12/01/2004 10.00 12.00
11/30/2004 2.00 2.00

I Understand that the problem in sorting. Can u please help in this regard.
Thanks well in advance
SK"

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-12-06 : 11:06:01
It looks like you are ordering by Delivery desc not by Delivery_Date desc !
One of those days...

rockmoose
Go to Top of Page
   

- Advertisement -