?
Solved

SQL Query Help

Posted on 2008-10-30
2
Medium Priority
?
182 Views
Last Modified: 2012-05-05
I have a web site with a membership table (id, lastname, firstname, dateregistered, etc.) and a sessions table (membership id, dateloggedin, etc.) which has a record for each date/time a member has logged into the site. I am trying to determine active members determined by if they have logged into the system within the kast 6 months. I only want to know if they have logged in at least once, I don't want to cound each time they have logged in over the last 6 months. I would like some help on how to write a sql query to give me the results.
0
Comment
Question by:elemke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
calpurnia earned 1000 total points
ID: 22844112
Assuming your tables are called Membership and Sessions, try something like:

SELECT DISTINCT M.* FROM Sessions S INNER JOIN Membership M
ON M.id=S.[membership id]
WHERE dateloggedin > Date()-183;

It'll depend on what flavour of SQL you're using (the above is the variety used by Access). You'll also save yourself some potential headaches if you avoid field names with spaces in.

0
 

Author Closing Comment

by:elemke
ID: 31511722
Thank you so much, this is exactly what I needed!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question