Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL sort alphabetically 1

Status
Not open for further replies.

YDDesign

Programmer
Jul 27, 2010
3
CA
What I am trying to accomplish is alphabetical sorting daily. For example on day one I would like it to sort litings from a-z, the following day b-a, the next day c-b and so on. Once it gets to z-a the next day would be back to a-z. Is this possible? I appreciate any help I can get with this as my brain hurts thinking about how to pull this one off!

Cheers!
 
could you please give some sample rows of data to illustrate what you mean by "b-a" and "c-b" and "z-a"

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Basically I am listing bed and breakfast locations in alphabetical order however A would get top spot always, so I would like the top position to rotate one from the bottom to the top every day,
ABCDEFGHIJKLOMOPQRSTUVWXYZ the next day ZABCDEFGHIJKLMNOPQRSTUVWXY the next day YZABCDEFGHIJKLMNOPQRSTUVWX and so on.

Hope that helps :) Thanks again!
 
ORDER BY
CASE WHEN LEFT(somecol,1) >= 'Z' THEN 0 ELSE 1 END, somecol

ORDER BY
CASE WHEN LEFT(somecol,1) >= 'Y' THEN 0 ELSE 1 END, somecol

ORDER BY
CASE WHEN LEFT(somecol,1) >= 'W' THEN 0 ELSE 1 END, somecol

...

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top