If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Multiple sorts... totally lost

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-10, 05:51
daily daily is offline
Registered User
 
Join Date: Feb 2010
Posts: 1
Multiple sorts... totally lost

Hi, all...

First of all I'm a newbie with databases so I need some help or at least starting points where start solving this problem.

My db looks like this:
Code:
+-----+------+-----+-------+----------+----------+----------+
| Bib | Name | Sex | Track | Split1   | Split2   | Time     |
+-----+------+-----+-------+----------+----------+----------+
| 1   | n1   | M   | 50    | 00:53:43 | 01:23:45 | 02:33:46 |
+-----+------+-----+-------+----------+----------+----------+
| 2   | n2   | M   | 50    | 00:52:43 | 01:24:45 | 00:00:00 |
+-----+------+-----+-------+----------+----------+----------+
| 3   | n3   | M   | 50    | 01:01:43 | 00:00:00 | 00:00:00 |
+-----+------+-----+-------+----------+----------+----------+
| 4   | n4   | M   | 50    | 00:00:00 | 00:00:00 | 00:00:00 |
+-----+------+-----+-------+----------+----------+----------+
| 5   | n5   | N   | 50    | 00:58:43 | 01:28:45 | 02:46:34 |
+-----+------+-----+-------+----------+----------+----------+
| 6   | n6   | M   | 32    | 00:32:45 | 00:00:00 | 01:33:52 |
+-----+------+-----+-------+----------+----------+----------+
| 7   | n7   | N   | 32    | 00:53:43 | 01:23:45 | 02:33:46 |
+-----+------+-----+-------+----------+----------+----------+
I need to sort this table so that I get overall rank of each track. I need to sort rank starting with finished competitors, then continue sort by split2 and split1 (both men and women in same) and ignore all competitors with no time att all. Then sort rank with just women.

So that after sort the table would look like this:
Code:
+-----+------+-----+-------+----------+----------+----------+------+-------+
| Bib | Name | Sex | Track | Split1   | Split2   | Time     | Rank | RankW |
+-----+------+-----+-------+----------+----------+----------+------+-------+
| 1   | n1   | M   | 50    | 00:53:43 | 01:23:45 | 02:33:46 | 1    |       |
+-----+------+-----+-------+----------+----------+----------+------+-------+
| 5   | n5   | N   | 50    | 00:58:43 | 01:28:45 | 02:46:34 | 2    | 1     |
+-----+------+-----+-------+----------+----------+----------+------+-------+
| 2   | n2   | M   | 50    | 00:52:43 | 01:24:45 | 00:00:00 | 3    |       |
+-----+------+-----+-------+----------+----------+----------+------+-------+
| 3   | n3   | M   | 50    | 01:01:43 | 00:00:00 | 00:00:00 | 4    |       |
+-----+------+-----+-------+----------+----------+----------+------+-------+
| 6   | n6   | M   | 32    | 00:32:45 | 00:00:00 | 01:33:52 | 1    |       |
+-----+------+-----+-------+----------+----------+----------+------+-------+
| 7   | n7   | N   | 32    | 00:53:43 | 01:23:45 | 02:33:46 | 2    | 1     |
+-----+------+-----+-------+----------+----------+----------+------+-------+
Bib = Starting number

Is this possible? I know the needed data is there, but with my skills I cannot get it out.

Any tips would be great.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On