MySQL Forums
Forum List  »  German

Anzahl an Datensätze begrenzen
Posted by: Michael Nonnast
Date: September 14, 2016 09:05AM

Hallo,
wie muss ich meine Abfrage ändern/ergänzen, damit ich nur die 10 größten Ausgaben je Monat bekomme?

SELECT
f_zr_deutsch(date_format(buchungstag,'%b')) AS 'Monat'
, YEAR(buchungstag) AS 'Jahr'
, sum(betrag) * (-1) AS 'Ausgaben'
, zr_gru(buchungstag, 'M') AS mz
, empfänger
FROM
michael.konto
WHERE
betrag < 0
AND YEAR(buchungstag) >= 2014
GROUP BY
empfänger
, YEAR(buchungstag)
, date_format(buchungstag,'%c')
ORDER BY
Jahr
, zr_gru(buchungstag,'M')
, sum(betrag) ASC ;

Das Ergebnis bringt mir alle Ausgaben im Monat.
Danke im Voraus
Michael

Options: ReplyQuote


Subject
Views
Written By
Posted
Anzahl an Datensätze begrenzen
1836
September 14, 2016 09:05AM


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.