Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 581945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:38:02+00:00 2026-05-13T14:38:02+00:00

I have 2 tables from which i need to run a query to display

  • 0

I have 2 tables from which i need to run a query to display number of views a user had in the last 3 months from now.

So far I have come up with: all the field types are correct.

 SELECT dbo_LU_USER.USERNAME
 , Count(*) AS No_of_Sessions
 FROM dbo_SDB_SESSION 
   INNER JOIN dbo_LU_USER 
     ON dbo_SDB_SESSION.FK_USERID = dbo_LU_USER.PK_USERID
 WHERE (((DateDiff("m",[dbo_SDB_SESSION].[SESSIONSTART],Now()))=0 
   Or (DateDiff("m",[dbo_SDB_SESSION].[SESSIONSTART],Now()))=1 
   Or (DateDiff("m",[dbo_SDB_SESSION].[SESSIONSTART],Now()))=2))
 GROUP BY dbo_LU_USER.USERNAME;

Basically, the code above display a list of all records within the past 3 months; however, it starts from the 1st day of the month and ends on the current date, but I need it to start 3 months prior to today’s date.

Also to let you know this is SQL View in MS Access 2007 code.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:38:02+00:00Added an answer on May 13, 2026 at 2:38 pm

    Depending on how “strictly” you define your 3 months rule, you could make things a lot easier and probably efficient, by trying this:

    SELECT dbo_LU_USER.USERNAME, Count(*) AS No_of_Sessions 
    FROM dbo_SDB_SESSION 
    INNER JOIN dbo_LU_USER 
    ON dbo_SDB_SESSION.FK_USERID = dbo_LU_USER.PK_USERID 
    WHERE [dbo_SDB_SESSION].[SESSIONSTART] between now() and DateAdd("d",-90,now())
    GROUP BY dbo_LU_USER.USERNAME;
    

    (Please understand that my MS SQL is a bit rusty, and can’t test this at the moment: the idea is to make the query scan all record whose date is between “TODAY” and “TODAY-90 days”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a select from table which does not have column that tells when
HI, I have a large table from which i can query to get the
I have a table of data sorted by date, from which a user can
I have an ASP page which will query records from a DB Table and
I have two identical tables and need to copy rows from table to another.
I have a paradox table from a legacy system I need to run a
If you have a table which holds history (updates, deletes) from another table, how
I have a single entry output from a paradox table which is imported into
I have a table which is referenced by foreign keys on many other tables.
I have a table which holds flight schedule data. Every schedule have an effective_from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.