MySQL Forums
Forum List  »  German

Zwei SELECT Anweisungen zur einer zusammenführen
Posted by: Rimm Markus
Date: August 19, 2009 12:26PM

Hallo,

ich würde gerne zwei SELECT Anweisungen zur einer zusammenführen, finde aber keinen brauchbaren Ansatz.

Vereinfacht dargestellt sieht es folgendermaßen aus.


TABELLE: testdb

id | datum | werte
----|------------|-------
1 | 2009-08-10 | aaaa
2 | 2009-08-10 | bbbb
3 | 2009-08-10 | cccc
4 | 2009-08-10 | aaaa
5 | 2009-08-17 | bbbb
6 | 2009-08-17 | cccc
7 | 2009-08-17 | dddd
8 | 2009-08-17 | aaaa
9 | 2009-08-17 | aaaa
10 | 2009-08-17 | cccc


Anweisungen:

SELECT COUNT(*) AS `thiscounter`, `werte` FROM `testdb`
WHERE `datume`>='2009-08-17'
GROUP BY `werte` ORDER BY `thiscounter` DESC LIMIT 3;

SELECT COUNT(*) AS `lastcounter`, `werte` FROM `testdb`
WHERE `datum`<'2009-08-17'
GROUP BY `werte`;


Gewünschte Ausgabe:

thiscounter | lastcounter | werte
------------|-------------|-------
2 | 2 | aaaa
1 | 1 | bbbb
2 | 1 | cccc


Über Lösungsvorschläge würde ich mir sehr freuen, und bedanke mich schon mal im Voraus.

Markus

Options: ReplyQuote


Subject
Views
Written By
Posted
Zwei SELECT Anweisungen zur einer zusammenführen
4371
August 19, 2009 12:26PM


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.