Solved

SQL Query Help

Posted on 2008-10-30
2
177 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
2 Comments
 
LVL 10

Accepted Solution

by:
calpurnia earned 250 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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