I have a procedure that return daily report between a time example (CreateDate BETWEEN ‘2012/1/21’ AND ‘2012/2/19’)
I want this result
1/21
1/22
1/23
.
2/1
.
.
But the output is sorted automatically based on the day!!As follows:
2/1
2/2
.
2/15
1/21
1/22
1/23
.
.
I cant using order by (createdate) because I have this select:
SELECT COUNT(UserId) AS c, DAY(CreateDate) AS d
FROM dbo.aspnet_Membership
WHERE (CreateDate BETWEEN '2012/1/21' AND '2012/2/19')
GROUP BY DAY(CreateDate)
If you want to sort by month and day, then you need month of course.
And you always need an ORDER BY to guarantee the result order.
In this case, the order you got was coincidence because of the GROUP BY (which implies an ORDER BY in MySQL, but not other RDBMS)