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

  • SEARCH
  • Home
  • 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 3305544
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:10:53+00:00 2026-05-17T21:10:53+00:00

I’m working in Microsoft SQL Server 2005 and need to do an analysis of

  • 0

I’m working in Microsoft SQL Server 2005 and need to do an analysis of players who qualify for our 50+ tournament on Tuesdays –> To qualify, they need to get 5+ points on Mon or Tues that week before 2pm, and the points are not cumulative (must get a min of 5 on Mon or on Tues before 2pm). The code I am using is below but so far only contains a date range for a specific Monday and Tuesday. I need all Mondays and Tuesdays over a 2 month timeframe. I am new to this (kinda thrown in my lap as an extra duty so I am having to learn on the fly)…

So far, as I stated, I have been able to succeed on my own in getting all the information I need but it is only specific to 1 week. Everything I have found online so far has been more confusing than I can explain and nobody has referenced the code I provided, instead giving me completely new code that I cannot use…

SELECT     
     dbo.CombinedPts.Account, dbo.CombinedPts.FirstName, 
     dbo.CombinedPts.LastName, 
     ISNULL(dbo.CombinedPts.EGSPts, 0) AS EGS, 
     ISNULL(dbo.CombinedPts.IRPts, 0) AS IR, 
     DATENAME(dw, dbo.CombinedPts.Date) AS WkDay, 
     DATEDIFF(YY, dbo.PlayerMaster.Birthdate, {fn current_date()}) - CASE WHEN   (MONTH(dbo.PlayerMaster.Birthdate)=MONTH({fn current_date()}) AND DAY(dbo.PlayerMaster.Birthdate) > DAY({fn current_date()}) OR MONTH (dbo.PlayerMaster.Birthdate) > MONTH ({fn current_date()}))  THEN 1   ELSE 0   END   AS Age
FROM       
     dbo.CombinedPts, dbo.PlayerMaster 
WHERE      
     (DATEDIFF(YY, dbo.PlayerMaster.Birthdate, {fn current_date()}) >= 50) 
     AND (dbo.CombinedPts.EGSPts >= 5 OR dbo.CombinedPts.IRPts >= 5) 
     AND (dbo.CombinedPts.Account = dbo.PlayerMaster.Account) 
     AND (Date BETWEEN '10/11/2010 00:00:00' AND '10/11/2010 13:59:59' OR Date BETWEEN '10/12/2010 00:00:00' AND '10/12/2010 13:59:59') 
     AND (DATEPART(dw, dbo.CombinedPts.Date) = 2 OR DATEPART(dw, dbo.CombinedPts.Date) = 3)
GROUP BY   
     dbo.CombinedPts.Account, 
     dbo.CombinedPts.FirstName, 
     dbo.CombinedPts.LastName, 
     DATENAME(dw, dbo.CombinedPts.Date), 
     dbo.CombinedPts.EGSPts, 
     dbo.CombinedPts.IRPts, 
     dbo.PlayerMaster.Birthdate
ORDER BY
     dbo.CombinedPts.Account

As a side note, in our SQL Server 2005, I do not have permissions to create subqueries (I have become an avid user of UNION ALL –> which has proved useless in the query so far) nor do I have permission to generate tables, so everything I do has to be in one query… And thus far, all help that has made some sense has been using tables and subqueries.

  • 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-17T21:10:53+00:00Added an answer on May 17, 2026 at 9:10 pm

    It’s a little different structure, but mostly the same. I used aliases instead of full references. It’s also untested, but parses cleanly.

    The AND DATEDIFF(m,cp.Date,GETDATE()) < 2 gives you the 2 month window.

    EDIT – Added the clauses for the Day and Time. AND (DATEPART(dw, cp.Date) in (2,3) AND DATEPART(hh,cp.Date) > 14) gives you only Monday and Tuesday after 2:00pm (1400 hours)

    SELECT cp.Account
    , cp.FirstName
    , cp.LastName
    , ISNULL(cp.EGSPts,0) AS EGS
    , ISNULL(cp.IRPts,0) AS IR
    , DATENAME(dw, cp.Date) AS WkDay
    , DATEDIFF(YY, pm.Birthdate, GETDATE()) 
            - CASE WHEN (MONTH(pm.Birthdate) = MONTH(GETDATE()) 
            AND DAY(pm.Birthdate) > DAY(GETDATE()) 
            OR MONTH (pm.Birthdate) > MONTH (GETDATE()) )
            THEN 1 
            ELSE 0 
            END AS Age
    
    FROM dbo.CombinedPts cp
    join dbo.PlayerMaster pm on cp.Account = pm.Account
    
    WHERE DATEDIFF(YY, pm.Birthdate, GETDATE()) >= 50
     AND (cp.EGSPts >= 5 OR cp.IRPts >= 5)
     AND (DATEPART(dw, cp.Date) in (2,3) AND DATEPART(hh,cp.Date) > 14)
     AND DATEDIFF(m,cp.Date,GETDATE()) < 2
    
    GROUP BY cp.Account
    , cp.FirstName
    , cp.LastName
    , DATENAME(dw, cp.Date)
    , cp.EGSPts
    , cp.IRPts
    , pm.Birthdate
    
    ORDER BY cp.Account
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.