This is a migrated thread and some comments may be shown as answers.

Issue with Month ordering

1 Answer 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 24 Jan 2012, 05:57 PM
I am pretty new to Telerik reporting. So I will try to explain the issues I am facing.

I have a report that binds to the following stored procedure
CREATE PROCEDURE GetSalesValue
 
AS
SELECT  DATENAME(mm, Sales.SaleOrderDate) AS MonthOfSale ,
        SUM(Quotes.NETPrice) AS SalesValue ,
        Source.Source
FROM    Quotes
        INNER JOIN Sales ON Quotes.QuoteId = Sales.QuoteId
        INNER JOIN Enquiry ON Quotes.EnquiryId = Enquiry.EnquiryId
        INNER JOIN Source ON Enquiry.SourceId = Source.SourceId
GROUP BY Sales.SaleOrderDate, Year(Sales.SaleOrderDate),
        Source.Source

this works as expected as in displaying the correct results in month order.  When this sproc gets bound to the report the months are in alphabetical order and not in month order. As you can see attached

I also tried to write the sproc differently and this works both with ASC and DESC

SELECT  DATENAME(mm, Sales.SaleOrderDate) AS MonthOfSale ,
        SUM(Quotes.NETPrice) AS SalesValue ,
        Source.Source
FROM    Quotes
        INNER JOIN Sales ON Quotes.QuoteId = Sales.QuoteId
        INNER JOIN Enquiry ON Quotes.EnquiryId = Enquiry.EnquiryId
        INNER JOIN Source ON Enquiry.SourceId = Source.SourceId
GROUP BY Sales.SaleOrderDate,
        Source.Source
ORDER BY MONTH(Sales.SaleOrderDate) ASC     


Is there a way around this?

Many thanks

1 Answer, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
answered on 25 Jan 2012, 10:52 AM
I got a work around for this.  Incase anyone is interested.  It is a bit of a hack but here goes

Stored Procedure or Query which ever you prefer as follows:

SELECT  DATENAME(mm, Sales.SaleOrderDate) AS MonthOfSale , MONTH(Sales.SaleOrderDate) AS MonthNumber,
        SUM(Quotes.NETPrice) AS SalesValue ,
        Source.Source
FROM    Quotes
        INNER JOIN Sales ON Quotes.QuoteId = Sales.QuoteId
        INNER JOIN Enquiry ON Quotes.EnquiryId = Enquiry.EnquiryId
        INNER JOIN Source ON Enquiry.SourceId = Source.SourceId
GROUP BY Sales.SaleOrderDate,
        Source.Source
ORDER BY MONTH(Sales.SaleOrderDate) ASC

Then in the report designer I added a new column for the Month Number which is sorted by ASC I then hid the column and all is working fine.
Tags
General Discussions
Asked by
Simon
Top achievements
Rank 1
Answers by
Simon
Top achievements
Rank 1
Share this question
or