Sorting - Classic asp putting a specific text @ the top of the table

micamb
micamb used Ask the Experts™
on
Hi all,

I've gotten a customer request. I have a task management system with various types of status. CompletedRecieved being one of them. My customer wants Recieved @ the top. However it's a Text based column in mySQL. I would normally sort either ASC or DESC, but neither puts Recieved @ the top. Anyway around this?

Best regards
Michael
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Team Lead
Commented:
>>I would normally sort either ASC or DESC, but neither puts Recieved @ the top. Anyway around this?

in your table: Task, just add another column called as seq (sequence), and then set the value of seq to 1 for Recieved, while set other records' seq to value greater than 1.

then change your query's order by to first order by seq ASC

like:
select * from Task order by seq, status

Open in new window

hope this make sense to you

Author

Commented:
Hi Ryan,

It does, but I was hoping to avoid that. I'll ponder over it for a while 'cause it's going to take some re-coding of the rest of my site.

I'll award you the points though as it is a sound solution.
Ryan ChongSoftware Team Lead

Commented:
if you do not want to have an additional column to determine the sequence ordering, then you will need to "hardcode" the ordering in your SQL statement, which in some cases, it's a valid solution.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial