Good evening, all. I'm trying to re-invent the wheel again purly in the interest of something to do that looks like work and makes me more employable else where.
I'm making a hit-counter that can track exit-points. It's going to do this by spotting the page on which the user was last seen.
There are a few rules:
1 - I can't use more than one SQL query... Stored procedures are right out... it's going to get messy.
2 - Users must have been inactive for more than two hours.
3 - MySQL 4.1 only! I can't afford MySQL 5.0 from my ISP yet!
My table:
My attempt so far:
As I'm sure many of you can see - it isn't working. I havn't even begun to figure out the two hour limit. I want a separate row for each trackId you see, and each trackId has a different MAX(`time`)
eBeer for the first person to help me! (or eWine, eJ2O, eWater, eTc, if you're not a beer person)
Yet another unchecked rambling brought to you by:
Oddball
I'm making a hit-counter that can track exit-points. It's going to do this by spotting the page on which the user was last seen.
There are a few rules:
1 - I can't use more than one SQL query... Stored procedures are right out... it's going to get messy.
2 - Users must have been inactive for more than two hours.
3 - MySQL 4.1 only! I can't afford MySQL 5.0 from my ISP yet!
My table:
Code:
+-------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------------------+------+-----+---------+----------------+
| hitId | int(10) unsigned | | PRI | NULL | auto_increment |
| browserId | int(10) unsigned | | MUL | 0 | |
| languagesId | int(10) unsigned | | MUL | 0 | |
| res_x | smallint(5) unsigned | YES | | NULL | |
| res_y | smallint(5) unsigned | YES | | NULL | |
| cDepth | tinyint(3) unsigned | YES | | NULL | |
| time | datetime | YES | | NULL | |
| referer | varchar(200) | YES | | NULL | |
| hitUrl | varchar(150) | YES | | NULL | |
| ip_num | int(10) unsigned | YES | | NULL | |
| username | varchar(255) | YES | | NULL | |
| trackId | varchar(100) | YES | MUL | NULL | |
+-------------+----------------------+------+-----+---------+----------------+
My attempt so far:
Code:
SELECT
hitUrl,
COUNT(*) AS count
FROM
page_hits
WHERE
hitId IN
(
SELECT
hitId
FROM
page_hits
GROUP BY
trackId
HAVING
`time` = GREATEST(`time`)
)
GROUP BY
hitUrl
As I'm sure many of you can see - it isn't working. I havn't even begun to figure out the two hour limit. I want a separate row for each trackId you see, and each trackId has a different MAX(`time`)
eBeer for the first person to help me! (or eWine, eJ2O, eWater, eTc, if you're not a beer person)
Yet another unchecked rambling brought to you by:
Oddball