Thomas Stockbruegger
asked on
SQL order of month and year
sql.Format("SELECT DATEPART(year,A.Liefersche indatum)AS year,\
DATEPART(month,A.Liefersch eindatum)A S month,\
SUM(B.Einheitbez13wert)AS Gewicht\
FROM Lieferscheine AS A , Lieferscheinpositionen AS B\
WHERE A.LieferscheinNr=B.Liefers cheinNr AND A.LieferscheinNr<200000\
GROUP BY DATEPART(month,A.Liefersch eindatum), \
DATEPART(year,A.Liefersche indatum)\
ORDER by DATEPART(month,A.Liefersch eindatum)A SC,\
DATEPART(year,A.Liefersche indatum)DE SC");
Hello,
In my SQL Table I have data from 2006 Januar till today 2013 May.
With my SQL code I will get the data in this order
year month
2013 Jan
2012 Jan
2011 Jan
.
.
.
2006 Jan
2013 Feb
2012 Feb
2011 Feb
.
.
.
2006 Feb and so on
But I would like to get the following order:
2006 Jan
2006 Feb
2006 Mar
2006 Apr
.
.
.
.
.
.
.
2013 May
Thank you for your help.
500 points with a solution.
Best regards,
Thomas
DATEPART(month,A.Liefersch
SUM(B.Einheitbez13wert)AS Gewicht\
FROM Lieferscheine AS A , Lieferscheinpositionen AS B\
WHERE A.LieferscheinNr=B.Liefers
GROUP BY DATEPART(month,A.Liefersch
DATEPART(year,A.Liefersche
ORDER by DATEPART(month,A.Liefersch
DATEPART(year,A.Liefersche
Hello,
In my SQL Table I have data from 2006 Januar till today 2013 May.
With my SQL code I will get the data in this order
year month
2013 Jan
2012 Jan
2011 Jan
.
.
.
2006 Jan
2013 Feb
2012 Feb
2011 Feb
.
.
.
2006 Feb and so on
But I would like to get the following order:
2006 Jan
2006 Feb
2006 Mar
2006 Apr
.
.
.
.
.
.
.
2013 May
Thank you for your help.
500 points with a solution.
Best regards,
Thomas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER