Solved

SQL Query Help

Posted on 2008-10-30
2
176 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
Comment Utility
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
Comment Utility
Thank you so much, this is exactly what I needed!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now