R
rjeffres
Hello,
Doing a quick query to tables already in system, so cannot edit the tables
or data. Trying to get counts of "Hits", like an advertisement hit, for
multiple time periods. Individual Selects work fine and so does the Nested
Select; however, if an Ad was not viewed for a given time period then 0 is
not shown and the history is not shown. I need help in the last WHERE clause
to be an Outer Join on table a, b, and c.
Here is the Nested Select:
SELECT a.Company, a.T14, b.T7, c.T1
FROM [SELECT Company, Count(*) as T14
FROM Company, Hits
where Company.Id = Hits.CompanyId
and CDate(Mid([HitTS],5,2) & "/" & Mid([HitTS],7,2) & "/" &
Left([HitTS],4)) >=Now() - 14
Group by Company]. AS a, [SELECT Company, Count(*) as T7
FROM Company, Hits
where Company.Id = Hits.CompanyId
and CDate(Mid([HitTS],5,2) & "/" & Mid([HitTS],7,2) & "/" &
Left([HitTS],4)) >=Now() - 7
Group by Company]. AS b, [SELECT Company, Count(*) as T1
FROM Company, Hits
where Company.Id = Hits.CompanyId
and CDate(Mid([HitTS],5,2) & "/" & Mid([HitTS],7,2) & "/" &
Left([HitTS],4)) >=Now() - 1
Group by Company]. AS c
WHERE a.Company = b.Company and a.Company = c.Company;
Doing a quick query to tables already in system, so cannot edit the tables
or data. Trying to get counts of "Hits", like an advertisement hit, for
multiple time periods. Individual Selects work fine and so does the Nested
Select; however, if an Ad was not viewed for a given time period then 0 is
not shown and the history is not shown. I need help in the last WHERE clause
to be an Outer Join on table a, b, and c.
Here is the Nested Select:
SELECT a.Company, a.T14, b.T7, c.T1
FROM [SELECT Company, Count(*) as T14
FROM Company, Hits
where Company.Id = Hits.CompanyId
and CDate(Mid([HitTS],5,2) & "/" & Mid([HitTS],7,2) & "/" &
Left([HitTS],4)) >=Now() - 14
Group by Company]. AS a, [SELECT Company, Count(*) as T7
FROM Company, Hits
where Company.Id = Hits.CompanyId
and CDate(Mid([HitTS],5,2) & "/" & Mid([HitTS],7,2) & "/" &
Left([HitTS],4)) >=Now() - 7
Group by Company]. AS b, [SELECT Company, Count(*) as T1
FROM Company, Hits
where Company.Id = Hits.CompanyId
and CDate(Mid([HitTS],5,2) & "/" & Mid([HitTS],7,2) & "/" &
Left([HitTS],4)) >=Now() - 1
Group by Company]. AS c
WHERE a.Company = b.Company and a.Company = c.Company;