I have the following query in a ASP page:
I would like to add another field (the first date of the entry) to the output of the recordset named logtimestamp in the database. I tried doing the following but I just keep getting join errors. I must be missing something easy but I can't see the forest through the trees. Been a long day.
Any help would be greatly appreciated.
Thanks.
Swi
Code:
dbfilter=request.form("filter")
dbbegindate=request.form("begindate")
dbenddate=request.form("enddate")
if trim(dbbegindate) <> "" And trim(dbenddate) <> "" then
infosearchbuffer= "SELECT A.code AS Campaign, A.UniqueHits AS [Unique Hits], B.TotalHits AS [Total Hits] " & _
"FROM (SELECT code, Count(*) AS UniqueHits FROM (SELECT DISTINCT code, logip FROM log WHERE " & _
"logtimestamp >= #" & dbbegindate & " 12:00:00 AM# AND logtimestamp < #" & dbenddate & " 11:59:59 PM#) " & _
"AS T GROUP BY code) AS A INNER JOIN (SELECT code, Count(*) AS TotalHits FROM log WHERE " & _
"logtimestamp >= #" & dbbegindate & " 12:00:00 AM# AND logtimestamp < #" & dbenddate & " 11:59:59 PM# " & _
"GROUP BY code) AS B ON A.code = B.code;"
end if
rsinfo.Open infosearchbuffer,conQR,3,3
I would like to add another field (the first date of the entry) to the output of the recordset named logtimestamp in the database. I tried doing the following but I just keep getting join errors. I must be missing something easy but I can't see the forest through the trees. Been a long day.
Code:
dbfilter=request.form("filter")
dbbegindate=request.form("begindate")
dbenddate=request.form("enddate")
if trim(dbbegindate) <> "" And trim(dbenddate) <> "" then
infosearchbuffer= "SELECT A.logtimestamp As BegDate, A.code AS Campaign, A.UniqueHits AS [Unique Hits], B.TotalHits AS [Total Hits] " & _
"FROM (SELECT MIN(logtimestamp), code, Count(*) AS UniqueHits FROM (SELECT DISTINCT MIN(logtimestamp), code, logip FROM log WHERE " & _
"logtimestamp >= #" & dbbegindate & " 12:00:00 AM# AND logtimestamp < #" & dbenddate & " 11:59:59 PM#) " & _
"AS T GROUP BY code) AS A INNER JOIN (SELECT MIN(logtimestamp), code, Count(*) AS TotalHits FROM log WHERE " & _
"logtimestamp >= #" & dbbegindate & " 12:00:00 AM# AND logtimestamp < #" & dbenddate & " 11:59:59 PM# " & _
"GROUP BY code) AS B ON A.code = B.code;"
end if
rsinfo.Open infosearchbuffer,conQR,3,3
Any help would be greatly appreciated.
Thanks.
Swi