Solved

SQL Query Help

Posted on 2008-10-30
2
179 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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.…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 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