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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:39:10+00:00 2026-06-09T22:39:10+00:00

Sorry if that wasn’t too clear but it is hard to sum up. Table

  • 0

Sorry if that wasn’t too clear but it is hard to sum up.

Table Holiday which has one field named hDate
Table TimeSheet which has tsDate,Code

Sample Data

   Holiday
   7/4/2012
   12/24/2012
   12/25/2012
   12/26/2012

Sample Data

   TimeSheet
   12/27/2012,W
   12/24/2012,H
   12/25/2012,W

I need to verify based on a date range that every record in the Holiday table that is between the date range exists in the Timesheet table and that they have an H value entered for Code

So if the date range passed in was 12/24-12/30 then the results should be empty since no data exists in timesheet for 12/26 and 12/25 has a code W in it. So basically I need an exists query to do this

  • 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-06-09T22:39:12+00:00Added an answer on June 9, 2026 at 10:39 pm

    You may try the following SQL. It counts the number of code <> ‘H’ and tsDate = null from the left outer join. If the count > 0, then return false.

    DECLARE @Holiday TABLE
    (
        hDate DATETIME NOT NULL
    )
    
    DECLARE @TimeSheet TABLE
    (
        tsDate DATETIME, 
        Code NCHAR(1)
    )
    
    INSERT INTO @Holiday (hDate)
    VALUES ('2012-07-04'), ('2012-12-24'), ('2012-12-25'), ('2012-12-26')
    
    INSERT INTO @TimeSheet (tsDate, Code)
    VALUES ('2012-12-27', 'W'), ('2012-12-24', 'H'), ('2012-12-25', 'W')
    
    DECLARE @StartDate DATETIME = '2012-12-24'
    DECLARE @EndDate DATETIME = '2012-12-30'
    
    SELECT 
        CASE WHEN COUNT(1) = 0 THEN 'TRUE' ELSE 'FALSE' END AS 'BooleanResult'
    FROM
        (
            SELECT hDate 
            FROM @Holiday 
            WHERE hDate BETWEEN @StartDate AND @EndDate
        ) H 
        LEFT JOIN @TimeSheet TS
        ON TS.tsDate = H.hDate
    WHERE 
        TS.Code != 'H' OR TS.tsDate IS NULL and 'H' not in (select doecode from timesheet 
    where timesheet.tsdate = TS.tsDate
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: OOPS, sorry I wasn't clear. I have a string that I get from
sorry if this question has been asked before, I searched but wasn't sure on
Sorry if that description isn't clear...wasn't sure how else to put it. I have
Sorry for the odd question but this is one that makes me want to
Sorry if this has already been asked somewhere, but I wasn't able to find
Sorry that I haven't done much of my own research but I do not
Sorry that I can't find the answer through google - But I know this
I'm sorry that I haven't deeply understood HBase and Hadoop MapReduce, but I think
first of all, sorry if that question is dumb but I´m a total newbie
This is going to sound too silly / too basic - sorry about that,

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.