Veröffentlicht 20. März 200619 j 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
20. März 200619 j 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)...
20. März 200619 j Wow, danke für die schnelle Antwort. Ich hab mal das Ergebnis als .pdf angehängt. Irgendwie ist die Ausgabe unkorrekt.Ergebnis (1).pdf
20. März 200619 j 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
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.