MySQL Forums
Forum List  »  German

Re: Spalten und Zeilen aus einer Tabelle erstellen
Posted by: Katja Kahl
Date: February 16, 2015 03:25PM

Hallo Ronny,
was du suchst, ist eine sogenannte Pivot-Tabelle.
Sofern die Anzahl der Filialen halbwegs im Rahmen bleibt, kannst du es wie folgt lösen:

Select Verkäufer
,sum( if(Filiale = 'A', Umsatz, 0) ) as A
,sum( if(Filiale = 'B', Umsatz, 0) ) as B
...
From <Tabelle>
Group By Verkäufer;

Die Umsätze werden nach Verkäufer summiert. Durch die if-Anweisung erfolgt die Summierung immer nur über die entsprechende Filiale.
Du kannst das Datum bei Bedarf einschränken (where Datum between 2015-01-01 and 2015-01-31). Der where-Teil gehört dann zwischen from und Group by.

Gruß Katja

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Spalten und Zeilen aus einer Tabelle erstellen
963
February 16, 2015 03:25PM


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.