MySQL Forums
Forum List  »  German

ORDER BY vor GROUP BY
Posted by: Stephan Schulze
Date: October 26, 2007 08:28AM

Hallo,

das folgende Problem ist mir schon mehrmals über den Weg gelaufen ohne das ich eine
Lösung dafür gefunden habe. Ich kann mir aber nicht vorstellen, dass es nicht mit
Hilfe der Datenbank zu lösen ist.

Über mehrere Joins wird eine Ergebnistabelle ermittelt, die in etwas so aussieht:

Die erste Spalte ist eine ID, die zweite ein Status und die Dritte das entsprechende Datum.

10008454 | confirmed | 2007-10-26 15:53:45
10008454 | confirmed | 2007-08-30 11:30:22
10008454 | confirmed | 2007-08-30 11:30:17
10008454 | confirmed | 2007-08-30 11:30:10

10008453 | confirmed | 2007-08-30 11:30:22
10008453 | confirmed | 2007-07-25 11:30:17
10008453 | confirmed | 2007-06-01 11:30:22
10008453 | confirmed | 2007-05-30 11:30:17

Als Ergebnis möchte ich sowas haben wie:
10008454 | confirmed | 2007-10-26 15:53:45
10008453 | confirmed | 2007-08-30 11:30:22

Also ein GROUP BY id der mir auch den Eintrag mit dem neusten Datum liefert.

Mache ich über die oben gezeigte ein GROUP BY id ORDER BY datum DESC
wird immer das älteste Datum angezeigt.

Irgendeine Idee wie man das löst?

Schon einmal vorab vielen Dank.

Viele Grüße

Stephan Schulze

Options: ReplyQuote


Subject
Views
Written By
Posted
ORDER BY vor GROUP BY
25540
October 26, 2007 08:28AM
12949
October 29, 2007 02:19AM
12044
November 03, 2007 05:26PM
10902
March 07, 2008 07:24AM


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.