Posted on: 12/23/2014 2:46:30 AM | Views : 634

Hi all.
I have two query. query 1 dislay table by month name. Query two display table by workingweek. I union the two table but the problem is table 1 display not in correct order for month name.
I want to display like this:
October
November
WW52

SELECT Month, InputQuantity, ShippingQuantity FROM ( SELECT DATENAME(MONTH, dbo.SBR.SBR_DateCreated) AS Month, SUM(dbo.SBR.SBR_Quantity) AS InputQuantity, SUM(dbo.SBR.SBR_ShippingQuantity) AS ShippingQuantity FROM dbo.SBR WHERE DATENAME(MONTH, SBR_DateCreated) <> DATENAME(MONTH, GETDATE()) GROUP BY DATENAME(MONTH, dbo.SBR.SBR_DateCreated) UNION SELECT dbo.SBR.SBR_WorkingWeek AS Month, SUM(dbo.SBR.SBR_Quantity) AS InputQuantity, SUM(dbo.SBR.SBR_ShippingQuantity) AS ShippingQuantity FROM dbo.SBR INNER JOIN dbo.WorkingWeek ON dbo.SBR.SBR_WorkingWeek=dbo.WorkingWeek.WorkingWeek WHERE (dbo.WorkingWeek.DateFrom < GETDATE() AND dbo.WorkingWeek.DateT ...

Go to the complete details ...