MySQL Lists are EOL. Please join:

List:German« Previous MessageNext Message »
From:BG Date:January 15 2019 7:03pm
Subject:AW: GROUP BY + COUNT
View as plain text  
Habe gerade noch folgende Query versucht, die aber auch nicht zum
gewünschten Ergebnis führt :(

SELECT 

IF(a1=1,'Mercedes', 
IF(a2=1,'BMW', 
IF(a3=1,'Ford',
IF(a4=1,'VW',
'NO')))) AS marke,

IF(a1=1,(SELECT COUNT( autos.id) FROM marke WHERE a1=1), 
IF(a2=1,(SELECT COUNT( autos.id) FROM marke WHERE a2=1),
IF(a3=1,(SELECT COUNT( autos.id) FROM marke WHERE a3=1),
IF(a4=1,(SELECT COUNT( autos.id) FROM marke WHERE a4=1),
'NO')))) AS anzahl

FROM autos 

WHERE autos.land=de GROUP BY marke ORDER BY anzahl DESC

Keiner einen Tipp?
Liest hier überhaupt jemand mit?

Grüße
Bert

Thread
GROUP BY + COUNTBG15 Jan
  • AW: GROUP BY + COUNTBG15 Jan
    • AW: GROUP BY + COUNTBG15 Jan
      • Re: GROUP BY + COUNTMartin Wildgruber15 Jan
        • AW: GROUP BY + COUNTBG15 Jan
    • Re: GROUP BY + COUNTFrank Rasche15 Jan