MySQL Forums
Forum List  »  Newbie

Re: grouping query results in their order
Posted by: David King
Date: August 19, 2009 02:18PM

So I made a little progress...

"SELECT Loc, Start_Time FROM (SELECT IF(@loc<>Location, Location, NULL) AS Loc, @loc=Location AS foo, Time as Start_Time FROM tbl WHERE Person="P1" ORDER BY Date) AS tbl1 WHERE Loc IS NOT NULL;"

Which gets me

| Loc | Start_Time |
| L1 | 10:00 |
| L2 | 11:00 |
| L1 | 12:00 |

Now I just need to find a way to get the End_Time

Options: ReplyQuote


Subject
Written By
Posted
Re: grouping query results in their order
August 19, 2009 02:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.