I am exporting from SQL Server to Excel from a saved view. In that view it is sorted by two columns (order by..)
But when I export it, it is randomly sorted in Excel.
How to export with the order by?
Here is the query of the view:
SELECT TOP (100) PERCENT GETDATE() AS Date, MixStatusID AS Partner, SUM(CAST(Weight AS
float)) AS Weight, SUM(CAST(TotalCostPrice AS float)) AS TotalCost, ProductGroupID
FROM dbo.D_ParcelLocation
WHERE (ParcelStatusID IN (N'stock', N'memo', N'transfer', N'analyze_un')) AND (ParcelTypeID <> N'M') AND (ProductGroupID <> N'G_POL') AND (ProductGroupID <> N'G_ROU')
GROUP BY MixStatusID, ProductGroupID
HAVING (SUM(CAST(Weight AS float)) > 0)
ORDER BY ProductGroupID, Partner