![]() |
Re: Mehrere Counts ausführen
Okay, schau ich mir an. Gut, dass ich mitm Kreuz keine Probleme hab :mrgreen:
EDIT: guuuutttt....
SQL-Code:
Damit kann ich wohl schonmal die Counts einzeln holen, nehm ich an.
SELECT COUNT(CASE [is_main_cat] WHEN 1 THEN * ELSE 0 END) as maincount, COUNT(CASE [is_main_cat] WHEN 0 THEN * ELSE 0 END) as seccount FROM ber_catlinks GROUP BY cat_id ORDER BY cat_id ASC
wenn ich das ganze jetzt auf meine query erweitere, muss ich das praktisch nur so splitten:
SQL-Code:
Werd gegebenenfalls heut abend nochmal dezent pushen, falls du bis dahin nichtgeantwortet hast ;-)
SELECT cats.id as id, cats.parent as parent, cats.name as name, cats.info as info, COUNT(CASE [is_main_cat] WHEN 1 THEN * ELSE 0 END) as maincount, COUNT(CASE [is_main_cat] WHEN 0 THEN * ELSE 0 END)
FROM ber_cats as cats, ber_catlinks as links WHERE cats.id = links.cat_id GROUP BY cats.id, cats.parent, cats.name, cats.info ORDER BY cats.id ASC EDIT: ist auch überhaupt nicht dringend. Werd da vor am sql sowieso nicht weiterarbeiten. |
Re: Mehrere Counts ausführen
Hallo,
ich habe das gerade mal unter Firebird probiert (allerdings nur mit wenigen Datensätzen):
SQL-Code:
Schau mal, ob das so passt.
select cats.id, cats.name, cats.parent, cats.info,
(select count(*) from links where links.is_main_cat = 0 and cats.id = links.cat_id) as Anz_0, (select count(*) from links where links.is_main_cat = 1 and cats.id = links.cat_id) as Anz_1 from cats left join links on cats.id = links.cat_id group by cats.id, cats.name, cats.parent, cats.info |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:35 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz