dbTalk Databases Forums  

Summenfunktion mitGroup by

comp.databases.mysql comp.databases.mysql


Discuss Summenfunktion mitGroup by in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
nerodrom@googlemail.com
 
Posts: n/a

Default Summenfunktion mitGroup by - 01-09-2007 , 04:16 PM






Hallo,

ich hab ein Problem mit folgender Abfrage in Form von.

SELECT ID, SUM(Anzahl)
FROM ...
WHERE...
GROUP BY ID

Folgendes Ergebnis wird angezeigt:

ID |SUM(Anzahl)
01|4
02|2
03|1
04|0
05|2

Jedoch möchte ich wissen, wieviele IDs mit beispielsweise der Summe 2
existieren.
D.h. die Tabelle sollte so ausschauen:

Sum(Anzahl) | Summe der IDs
0|1
1|1
2|2
4|1

Hat einer ne Idee wie ich das hinbekomme? Schon mal vielen Dank im
Voraus!!

/Robert Nestler


Reply With Quote
  #2  
Old   
Paul Lautman
 
Posts: n/a

Default Re: Summenfunktion mitGroup by - 01-10-2007 , 02:14 AM






nerodrom (AT) googlemail (DOT) com wrote:
Quote:
Hallo,

ich hab ein Problem mit folgender Abfrage in Form von.

SELECT ID, SUM(Anzahl)
FROM ...
WHERE...
GROUP BY ID

Folgendes Ergebnis wird angezeigt:

ID |SUM(Anzahl)
01|4
02|2
03|1
04|0
05|2

Jedoch möchte ich wissen, wieviele IDs mit beispielsweise der Summe 2
existieren.
D.h. die Tabelle sollte so ausschauen:

Sum(Anzahl) | Summe der IDs
0|1
1|1
2|2
4|1

Hat einer ne Idee wie ich das hinbekomme? Schon mal vielen Dank im
Voraus!!

/Robert Nestler
Could you post the actual table data that led to this result?




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.