Hallo zusammen,

ich habe eine Tabelle mit folgendem Aufbau:

ID (int) - BannerID (varchar) - Clicked (int) - Datum (DateTime)

Die Spalte clicked ist entweder mit einer 0 (Views) oder einer 1
(Clicks) gefüllt.

Die sql-Anweisung:

SELECT COUNT(*) AS Anzahl,DATEPART(hh, Datum) AS Uhrzeit, clicked FROM
[log] WHERE BannerID = '311020051312002656' AND Datum >= '02.02.2006'
AND Datum <= '02.02.2006 23:59:59' AND Clicked = 0 GROUP BY
DATEPART(hh, Datum) ORDER BY DATEPART(hh, Datum)

gibt mir die Views pro Stunde für einen bestimmten Banner zurück.

und die Anweisung:

SELECT COUNT(*) AS Anzahl,DATEPART(hh, Datum) AS Uhrzeit, clicked FROM
[log] WHERE BannerID = '311020051312002656' AND Datum >= '02.02.2006'
AND Datum <= '02.02.2006 23:59:59' AND Clicked > 0 GROUP BY
DATEPART(hh, Datum) ORDER BY DATEPART(hh, Datum)

gibt mir die Clicks pro Stunde für einen bestimmten Banner zurück.

So weit, so gut. Ich möchte die sql-Anweisung jetzt gerne so anpassen,
dass ich die Clicks (clicked > 0) und die Views (clicked = 0) zusammen
mit der aktuellen Stunde zurück bekomme:

Beispiel:

Stunde Views Clicks
10     150   60
11     145   78
12     138   12

Ist das möglich? Ich habe schon mehrere Versuche mit Sub-Selects
unternommen, bin aber an der Verbindung zur Stunde (GROUP BY
Datepart(hh, Datum)) gescheitert.

Vielen Dank für Eure Hilfe...

Viele Grüße

Tim
_______________________________________________
Coffeehouse Mailingliste, Postings senden an:
[email protected]
An-/Abmeldung und Suchfunktion unter:
http://www.glengamoi.com/mailman/listinfo/coffeehouse

Antwort per Email an