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 7493645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:06:09+00:00 2026-05-29T17:06:09+00:00

I having this problem with query these two table do not have any link

  • 0

I having this problem with query these two table do not have any link between and I am trying to combine. Table 1 have effective and expiration date in which have to be tied to table 2 of PollDate. PollDate must not lies in between the effective and expiration date.

Table 1
ClientID    EffectiveDate       ExpirationDate
1       2009-04-01 00:00:00.000 2009-12-18 00:00:00.000
1       2010-02-12 00:00:00.000 2010-03-05 00:00:00.000
1       2010-05-18 00:00:00.000 NULL
1       2009-12-21 00:00:00.000 2010-02-08 00:00:00.000
1       2010-12-19 00:00:00.000 2009-12-20 00:00:00.000

Table 2
ClientID    PollDate
1       2009-12-20 00:00:00.000
1       2009-12-19 00:00:00.000
1       2010-02-12 00:00:00.000
1       2010-02-27 00:00:00.000
1       2010-05-19 00:00:00.000
1       2010-05-29 00:00:00.000
1       2010-05-30 00:00:00.000
1       2010-05-31 00:00:00.000
1       2010-06-05 00:00:00.000
1       2010-06-25 00:00:00.000
1       2010-06-27 00:00:00.000
1       2010-07-02 00:00:00.000
1       2010-08-04 00:00:00.000
1       2010-08-20 00:00:00.000

Result
ClientID    inValidDate
1       2009-12-20 00:00:00.000
1       2009-12-19 00:00:00.000    
  • 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-29T17:06:10+00:00Added an answer on May 29, 2026 at 5:06 pm

    The following is a slight variation of @AJP’s result – just accounting for NULL values in ExpirationDate:

    CREATE TABLE #Table1
    (
        [ClientID] INT,
        [EffectiveDate] DATETIME,
        [ExpirationDate] DATETIME
    )
    
    INSERT INTO #Table1
    (
        [ClientID],
        [EffectiveDate],
        [ExpirationDate]
    )
    SELECT 1, '2009-04-01', '2009-12-18' UNION
    SELECT 1, '2010-02-12', '2010-03-05' UNION
    SELECT 1, '2010-05-18', NULL UNION
    SELECT 1, '2009-12-21', '2010-02-08' UNION
    SELECT 1, '2010-12-19', '2009-12-20'
    
    CREATE TABLE #Table2
    (
        [ClientID] INT,
        [PollDate] DATETIME
    )
    
    INSERT INTO #Table2
    (
        [ClientID],
        [PollDate]
    )
    SELECT 1, '2009-12-20' UNION
    SELECT 1, '2009-12-19' UNION
    SELECT 1, '2010-02-12' UNION
    SELECT 1, '2010-02-27' UNION
    SELECT 1, '2010-05-19' UNION
    SELECT 1, '2010-05-29' UNION
    SELECT 1, '2010-05-30' UNION
    SELECT 1, '2010-05-31' UNION
    SELECT 1, '2010-06-05' UNION
    SELECT 1, '2010-06-25' UNION
    SELECT 1, '2010-06-27' UNION
    SELECT 1, '2010-07-02' UNION
    SELECT 1, '2010-08-04' UNION
    SELECT 1, '2010-08-20'
    
    SELECT
        t2.[ClientID],
        t2.[PollDate] AS 'inValidDate'
    FROM
        #Table1 AS t1
    JOIN
        #Table2 AS t2
    ON
        (t2.[PollDate] < t1.[EffectiveDate]
    OR  t2.[PollDate] > ISNULL(t1.[ExpirationDate], '9999-12-31'))
    AND t1.ClientID = t2.ClientID -- Not clear from your question if this is necessary
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i'm having this problem. I have two tables (Oracle), one is called Destination
I'm having trouble trying to define the SQL query for this table: There's a
For few days now I'm trying to solve this problem. I have table group_user,
Hey dudes.i am having this problem while symlinking. I have successfully deployed a ruby
I am facing problem with Inner join in Access Database. I have two table
Ive got a problem with a MySQL query. Let's say, we have two tables:
I'm having this problem, same as ever, but never try to find the right
I'm having this problem and I reached a deadlock, I would try anything I've
I'm having this problem with the grails liferay-plugin: localhost_liferay_portlet_WEB_INF_grails_app_views_test_view_gsp: 17: expecting anything but ''\n'';
We are having this problem with a controller right now; the controller looks like

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.