Zum Inhalt springen

Empfohlene Beiträge

Geschrieben

Hallo :-)

Hab mich ganz frisch im Forum angemeldet, und brauch eure Hilfe.

System: DB/2 von IBM.

Das Problem das ist, dass ich die Abfrage aus einer Tabelle mache, nämlich aus tabelle1. Also tabelle2 existiert nicht.

Ziel ist also folgendes:

Spalte 1: (Datum DD/MM/JJ) von Tabelle01

Spalte 2: (erflogreiche Suche (>0 Hits)) von Tabelle01

Spalte 3: (Null_Suche (=0 Hits)) von Tabelle01

Mein Ansatz bisher:

db2 "select tg.datum, count(td), count(tg) from

table(select datum, count(*) from tabelle where treffer = '0' group by datum) as td,

table (select datum, count(*) from tabelle where treffer > '0' group by datum) as tg

where td.datum = tg.datum group by tg.datum"

Fehler: SQL0206N "TD" is not valid in the context where it is used. SQLSTATE=42703

oder anderer Ansatz:

db2 "select tg.datum, count(td.datum) as AnzTab1, count(tg.datum) as AnzTab2

from table1 as td, table2 as tg

where td.datum = tg.datum AND td.treffer = '0' AND tg.treffer = '0'

group by tg.datum"

Ich bin ratlos :unsure:

Und wenn mir jemand helfen kann, bin ich echt dankbar ;)

liebe Grüße

MaXi

Geschrieben


db2 "select tg.datum, [B][COLOR="Red"]td.treffer[/COLOR][/B], [B][COLOR="Red"]tg.treffer[/COLOR][/B] from

table(select datum, count(*) [b][COLOR="Red"]treffer[/COLOR][/b] from tabelle

where [B][COLOR="Red"]treffer = 0[/COLOR][/B] group by datum) as td,

table (select datum, count(*) [B][COLOR="Red"]treffer[/COLOR][/B] from

tabelle where [B][COLOR="Red"]treffer > 0[/COLOR][/B] group by datum) as tg

where td.datum = tg.datum group by tg.datum"


oder mit count(td.*) anstelle von count(td)...

Geschrieben

Ich hab die Lösung :-)

db2 "select tg.datum, sum(td.treffer), sum(tg.treffer) from

table(select datum, count(*) treffer from tabelle

where treffer = 0 group by datum) as td,

table (select datum, count(*) treffer from

tabelle where treffer > 0 group by datum) as tg

where td.datum = tg.datum group by tg.datum"

Vieeeeelen Dank

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...