Hello I seem to be having a problem, I have this query that pulls back correct results
SELECT hourStamp, SUM(CASE WHEN datestamp < GETDATE() THEN 1 ELSE 0 END) / @numberofdays as HourAverage, SUM(CASE WHEN dateStamp BETWEEN DATEADD(d,DATEDIFF(d,0,GETDATE()),0) AND GETDATE() THEN 1 ELSE 0 END) as HourToday FROM webstats GROUP BY hourStamp ORDER BY hourStamp
I also have this query that pulls back correct results
SELECT hourstamp, COUNT(id) AS ActualVisits FROM webStats WHERE id IN (SELECT ws.id FROM webStats AS ws INNER JOIN webStatsTrace AS wst ON ws.id = wst.statsid WHERE (ws.datestamp BETWEEN DATEADD(d, DATEDIFF(d, 0, GETDATE()), 0) AND GETDATE()) GROUP BY ws.id HAVING (COUNT(wst.statsid) > 1)) GROUP BY hourstamp ORDER BY hourstamp
But i am unable to join the two querys, or rewrite them so i run one query and get all the results in one... could anyone please suggest a way?