Einzelnen Beitrag anzeigen

Namenloser

Registriert seit: 7. Jun 2006
Ort: Karlsruhe
3.724 Beiträge
 
FreePascal / Lazarus
 
#8

AW: HAVING mit MAX (alias)

  Alt 6. Jul 2012, 22:02
Hallo Philip,

ich benötige ja das Maximum einer (alias Spalte), die wiederum eine Aggregatfunktion nutzt.
Ah sorry, hatte ich irgendwie falsch gesehn.

Ich habe folgende Varianten anzubieten:
SQL-Code:
select
  id,
  count(*) as anz,
  (
    select max(anz)
    from (select count(*) as anz from Tabelle group by id) as tmp
  ) as maximum
from Tabelle
group by id
having anz=maximum
SQL-Code:
select id, count(*) as anz
from Tabelle
group by id
having
  (
    select max(anz)
    from (select count(*) as anz from Tabelle group by id) as tmp
  ) = anz

Geändert von Namenloser ( 7. Jul 2012 um 18:00 Uhr)
  Mit Zitat antworten Zitat