mmax Geschrieben 20. März 2006 Geschrieben 20. März 2006 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 Und wenn mir jemand helfen kann, bin ich echt dankbar liebe Grüße MaXi
geloescht_JesterDay Geschrieben 20. März 2006 Geschrieben 20. März 2006 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)...
mmax Geschrieben 20. März 2006 Autor Geschrieben 20. März 2006 Wow, danke für die schnelle Antwort. Ich hab mal das Ergebnis als .pdf angehängt. Irgendwie ist die Ausgabe unkorrekt.Ergebnis (1).pdf
mmax Geschrieben 20. März 2006 Autor Geschrieben 20. März 2006 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
Empfohlene Beiträge
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 erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde Dich hier an.
Jetzt anmelden