April 5, 2016 at 9:55 am
Hello. Pardon me, I'm new to both this forum and SQL.
I need assistance with code that will allow me to change the return order of week names. Currently, the return as the following:
Weeks 9,8,7,6,5,4,3,2,14,13,12,11,10,1 ... and so on
I need the data to return in current order, such as:
Weeks 14,13,12,11,10,9,8,7,6,5,4,3,2,1 ... and so on
How might I resolve this?
Thank you.
April 5, 2016 at 10:00 am
clbishop (4/5/2016)
Hello. Pardon me, I'm new to both this forum and SQL.I need assistance with code that will allow me to change the return order of week names. Currently, the return as the following:
Weeks 9,8,7,6,5,4,3,2,14,13,12,11,10,1 ... and so on
I need the data to return in current order, such as:
Weeks 14,13,12,11,10,9,8,7,6,5,4,3,2,1 ... and so on
How might I resolve this?
Thank you.
Select Week
from table
order by Week DESC
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
April 5, 2016 at 10:08 am
Phil Parkin (4/5/2016)
clbishop (4/5/2016)
Hello. Pardon me, I'm new to both this forum and SQL.I need assistance with code that will allow me to change the return order of week names. Currently, the return as the following:
Weeks 9,8,7,6,5,4,3,2,14,13,12,11,10,1 ... and so on
I need the data to return in current order, such as:
Weeks 14,13,12,11,10,9,8,7,6,5,4,3,2,1 ... and so on
How might I resolve this?
Thank you.
Select Week
from table
order by Week DESC
The Weeks column seems to be a string in his example Phil 🙁 ...
Cast them as INT first to get around this...hopefully there is nothing else in there to break this
Select Week
from table
order by CAST(Week as INT) DESC
April 5, 2016 at 10:09 am
what is the data type of "week"?
maybe if "week" is varchar then
ORDER BY cast(week as int) DESC
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply