Guest User

Untitled

a guest
Jul 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. Account Jan Feb Mar Apr etc…
  2. 101 1
  3. 101 2
  4. 102 3
  5. 103 4
  6. 103 5
  7.  
  8. Account Jan Feb Mar Apr etc…
  9. 101 2
  10. 102 3
  11. 103 3
  12. 104 2
  13. 105 3
  14.  
  15. SELECT [NewSalesHistory].[Region]
  16. ,[NewSalesHistory].[ShipTo]
  17. ,SUM(case when [NewSalesHistory].[billingdate] between '6/1/2016' and '6/30/2016' then newbillingdata else 0 end ) + [X].[Jun-16] AS 'Jun-16'
  18. FROM [NewSalesHistory]
  19. FULL join (SELECT [Shipto]
  20. ,SUM(case when [BWLease].[billingdate] between '6/1/2016' and '6/30/2016' then ExtPrice else 0 end ) as 'Jun-16'
  21. FROM [AirgasPricing].[dbo].[BWLease]
  22. GROUP BY [Shipto]) X ON [NewSalesHistory].[ShipTo] = [X].[Shipto]
  23.  
  24. GROUP BY [NewSalesHistory].[Region]
  25. ,[NewSalesHistory].[ShipTo]
  26. ,[X].[Jun-16]
Add Comment
Please, Sign In to add comment