Akhter HUssain

Akhter HUssain

  • 712
  • 1.3k
  • 103.2k

Report req Sum of Sales order qty and daily produce quantity

Jul 31 2019 3:52 AM
i want report in which sum of sales order qty of all (open) order and day wise produce qty require in a report here is my data and expected result...
 
 
  1. CREATE TABLE #SalesOrder (OrderNo INT,Order_Ref_No VARCHAR(50), Order_date date,Status Varchar(50));  
  2. CREATE TABLE #OrderDetail (IDOD INT,OrderNO int,CodeItem int,orderqty int);  
  3. CREATE TABLE #Sections (SecID INT,Secnam VARCHAR(50));  
  4. CREATE TABLE #ItemMasterFile(CodeItem INT,Descriptionitem VARCHAR(50),SecID INT,weight int);  
  5. CREATE TABLE #Probale(BID INT,CodeItem INT,prdQTY INT,Orderno int,weight int,Entrydate DATETIME,DelID int);  
  6. INSERT INTO #Sections VALUES(1,'HR'),(2,'Baby'),(3,'Ladies'),(4,'Mix Rammage'),(5,'T-Shirst'),(6,'Scrap'),(7,'Scrit'),(8,'Men'),(9,'HHR'),(10,'Sports'),(11,'m-HR'),(12,'M-Baby'),(13,'M-Ladies'),(14,'M-Mix Rammage'),(15,'m--Shirst'),(16,'M-Scrap'),(17,'M-Scrit'),(18,'M-Men'),(19,'M-HHR'),(20,'M-Sports');  
  7.   
  8. INSERT INTO #ItemMasterFile VALUES  
  9.   (1,'A',1,100)  
  10. , (2,'B',2,100)  
  11. , (3,'C',3,100)  
  12. , (4,'D',4,100)  
  13. , (5,'e',5,100)  
  14. , (6,'f',6,100)  
  15. , (7,'g',4,100)  
  16. , (8,'h',4,100)  
  17. , (9,'K',2,100)  
  18. , (10,'L',4,100)  
  19. , (11,'M',2,100);  
  20.   
  21.   
  22. INSERT INTO #Probale VALUES  
  23.    (1,1,1,001,100,'01-06-2019',null)  
  24. , (2,3,1,001,200,'02-06-2019',null)  
  25. , (3,11,1,002,200,'03-06-2019',null)  
  26. , (4,10,1,002,200,'08-06-2019',null)  
  27. , (4,1,1,003,200,'08-06-2019',null)  
  28. , (4,3,1,003,200,'08-06-2019',null);  
  29.   
  30. INSERT INTO #SalesOrder VALUES(001,'A_01','01-05-2019','Open')  
  31. , (002,'B_01','01-05-2019','Open')  
  32. , (003,'C_01','01-05-2019','Open');  
  33.   
  34. INSERT INTO #OrderDetail VALUES  
  35.   (1,001,1,5)  
  36. , (2,001,2,3)  
  37. , (3,001,3,2)  
  38. , (4,002,10,4)  
  39. , (5,002,11,3)  
  40. , (6,002,3,2)  
  41. , (7,003,1,4)  
  42. , (8,003,2,3)  
  43. , (9,003,3,2);  
here is my expected result...
 
 
 

Answers (9)