Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Count for Order Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, June 15, 2010 9:38 PM
 Forum Newbie Group: General Forum Members Last Login: Thursday, June 17, 2010 1:09 AM Points: 1, Visits: 7
 Tbl.OrderOrderID | OrderDate | RequiredDate | OrderStatus--------------------------------------------------Tbl.OrderDateOrderID | NewRequiredDate -------------------------OUTPUT:TotalOrder | CompletedOrderBeforeRequiredMonth|CompletedWithinDueMonth |                |                                                  |--------------------------|                 |                                                 | Before Or On|After Required|                |                                                 | RequiredDate| Date           |-----------------------------------------------------------------------------Total Order = All the total order not include the order that had been cancelled. But if the order is already completed before the month of required month (month of requiredDate), the total order should deduct this order that hv been completed before the required month. (Ex: Total Order that must be completed in May is 23.Then 2 had been cancelled and another 5 hd been completed during April So the total order in May = 23-2-5 = 16)CompletedOrderBeforeRequiredMonth = Order that hd been completed before reach its month of required date or new required date.CompletedWithinDueMonth : Before or on required date = Order is completed within the month that is before reach its required date or on required date.CompletedWithinDueMonth : After requred date = Order is completed after the required date but still in the same month*Required date mentioned above is refer to either RequiredDate in Tbl.Order or NewRequiredDate in Tbl.OrderDate*Status of order would be Completed,In progress or Cancelled.**I don't need update on required date since i need both RequiredDate and NewRequiredDate. If there is NewRequiredDate available, the calculation would be based on NewRequiredDate else if the NewRequiredDate is null, the RequiredDate will be taken. My major problem is how to calculate the Total Order. I am doing Stored Proc for repotring services. I already do outer join for both table but my calculation is wrong. Any idea would be great.I am new in SQL.I am using SQL Server 2005.
Post #937914
 Posted Wednesday, June 16, 2010 1:20 AM
 SSCommitted Group: General Forum Members Last Login: Friday, April 1, 2016 1:37 AM Points: 1,778, Visits: 8,370
 Please post DDL, sample data and the code you have so far.If you do you will probably get better responses.
Post #937967

 Permissions