I have SQL Server 2008R2 SSRS reports.
I'm using custom time dimension called Month_Year.
Reason for using Month_Year is that I would like to display month in format of 1/2013 to save space in parameter lenght.
Remember please that I'm using Interactive Sorting also. I have created special ORDER statement so that I get sorting correct.
I need help with following statement:
SELECT DISTINCT Month_Year
.ProductName
,SUM(SalesAmont)
FROM Sales
GROUP BY Month_Year,ProductName
ORDER BY RIGHT(Month_Year,4) + '' + LEFT(Month_Year,1) DESC
I get following error:
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
THIS IS SELECT Month_Year FROM Sales ORDER BY Month_Year:
Month_Year
6/2013
6/2013
6/2013
6/2013
6/2013
6/2012
6/2012
6/2012
5/2013 (this should be located after 6/2012 so I created new ORDER statement )
5/2012
4/2013
4/2012
4/2012
CREATE TABLE [dbo].[Calender](
[Date] [datetime] NOT NULL,
[MonthNumber] [numeric](2, 0) NOT NULL,
[Month_Year] [varchar](7) NULL,
)
CREATE TABLE [dbo].[Sales](
[Month_Year] [varchar](7) NULL,
[ProductName] [varchar](7) NULL,
[SalesAmount] [float] NOT NULL,
Kenny_I