473,756 Members | 3,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Counting users online with last hour

Hi,

I have a log table which contains the fields log_time (DATETIME) and
session_id (VARCHAR). Using these 2 columns I want to be able to SELECT the
number of users who have been online during the past hour. Getting the
number of rows logged in the last hour is easy but I can't work out how to
only count distinct session_id entries.

Thanks,

Mark
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004
Jul 20 '05 #1
2 2283
Not to worry. I think I've worked it out:

SELECT COUNT( DISTINCT (
session_id
) )
FROM log
WHERE DATE_SUB( CURDATE( ) , INTERVAL 30
DAY ) <= log_date

Mark

"Mark Jerzykowski" <ma************ **@ntlworld.com > wrote in message
news:Ge******** *******@newsfe2-gui.ntli.net...
Hi,

I have a log table which contains the fields log_time (DATETIME) and
session_id (VARCHAR). Using these 2 columns I want to be able to SELECT the number of users who have been online during the past hour. Getting the
number of rows logged in the last hour is easy but I can't work out how to
only count distinct session_id entries.

Thanks,

Mark
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004
Jul 20 '05 #2
Mark Jerzykowski wrote:
I have a log table which contains the fields log_time (DATETIME) and
session_id (VARCHAR). Using these 2 columns I want to be able to SELECT the
number of users who have been online during the past hour. Getting the
number of rows logged in the last hour is easy but I can't work out how to
only count distinct session_id entries.


Mark J. posted one method, but here is another for comparison:

SELECT MAX(log_time), session_id
FROM myTable
WHERE log_time > now() - interval 60 minute
GROUP BY session_id;

Regards,
Bill K.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7092
by: toedipper | last post by:
Hello, I am developing a site using php and mysql and I would like to be able to let visitors know how many other visitors are currently browsing the site i.e. 'There are currently x amount of visitors browsing this site' You can see this in action in the following sites but I am not sure what technology they use www.recruitni.com (about 1/3 down the page) and also www.scancom.co.uk on the left hand side.
2
488
by: Mark Jerzykowski | last post by:
Hi, I have a log table which contains the fields log_time (DATETIME) and session_id (VARCHAR). Using these 2 columns I want to be able to SELECT the number of users who have been online during the past hour. Getting the number of rows logged in the last hour is easy but I can't work out how to only count distinct session_id entries. Thanks,
3
2174
by: A Seel | last post by:
COUNTING NUMBER OF SELECTS MADE table mytable { id, data, hits }
5
2695
by: Cam Bevis | last post by:
I'm having trouble getting my head around this, and no one in the groups has posted exactly the problem. The table below tracks site traffic across a network. There is 1 row per pageview and UUID is that user's unique cookie. CREATE TABLE . ( NOT NULL , NULL , NULL ,
14
2527
by: Brian Maupin | last post by:
I have a refreshing webcam shot on my site and I was wondering if there was a way I could display how many people are currently viewing it? Thanks in advance.
1
3252
by: Tony Johansson | last post by:
Hello Experts! I reading a book called programming with design pattern revealed by Tomasz Muldner and here I read something that I don't understand completely. It says "A garbarage collector, such as the one used in Java, maintains a record of whether or not an object is currentlys being used. An unused object is tagged as garbage,
6
1829
by: edwardfredriks | last post by:
I'm looking for a script that, instead of counting down, can "count up" from a given date. So the output should be something like "(xx) days since (date/event)" or "(date/event) was (xx) days ago". Does anybody know where to find a script like that, or could someone code one for me? Thanks in advance. Yours,
5
5289
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the sessionstate inproc mode and users are randomly losing their session. I do not believe it is happening across all users at one time. It seems to happen to different users at different times, but I am only going off heresay. The aspnet worker...
9
1777
by: jab3 | last post by:
So I'm considering a small project that involves online file storage. Let's say I wanted to set up a site that allows people to log-on, create an account, and then have space to upload files. The problem I'm having concerns permissions, basically. 1) How do I automatically create users in Linux from a PHP script running under Apache's uid/gid? 2) Once 1 is done, how, when they log back on (authenticated with SQL which will keep up...
0
1423
by: fhmm | last post by:
hellow everybody i need your help i have problem in counting the waiting time for a person for example if we need to count the waiting time for a person from which he has come to the time 15:30 the programe should prompt for hour and minute to calculate the waiting time . thank you in advance,
0
9325
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9716
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9716
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9571
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8569
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4996
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.