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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:14:01+00:00 2026-05-30T21:14:01+00:00

Dear Programmers, I need to compare one column value to another column in single

  • 0

Dear Programmers,
I need to compare one column value to another column in single select query.

As my query goes like this:

    SELECT ATTNLOG.emp_id,
           ATTNLOG.tdate,
           ATTNLOG.tdate_out,
          (CASE WHEN EXISTS (SELECT * 
                               FROM tbl_emp_overtime 
                              WHERE emp_id=ATTNLOG.emp_id 
                                AND ot_indate=ATTNLOG.tdate)
               THEN 0 
               ELSE 1 
          END) as 'STATUS'
    FROM tbl_emp_attn_log ATTNLOG 
   WHERE ATTNLOG.emp_id=201

In my case condition i need to compare the every row of ATTNLOG and gives STATUS respectively.

Actually the result returns row values like

EMP_ID  TDATE     TDATE_OUT  STATUS
201    2012-2-26  2012-2-26   0
201    2012-2-27  2012-2-27   1

and the table tbl_emp_overtime has value like

emp_ID  ot_indate
201    2012-2-27

But my code gives like

EMP_ID  TDATE     TDATE_OUT  STATUS
201    2012-2-26  2012-2-26   1
201    2012-2-27  2012-2-27   1

But it don’t give the result like that. Please help me out.

  • 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-30T21:14:02+00:00Added an answer on May 30, 2026 at 9:14 pm

    If you use sql 2008 cast the dates to date data type, if the original data type is datetime it should help:

    SELECT * 
    FROM tbl_emp_overtime 
    WHERE emp_id=ATTNLOG.emp_id 
    AND CAST(ot_indate as DATE)=CAST(ATTNLOG.tdate AS DATE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear friends, I need your help. I need to send .bmp file to another
Dear all, I have a select query that currently produces the following results: DoctorName
Dear fellow programmers, I am working on my B&B's website www.bordemundo.com and would like
Dear Friends good afternoon. My problem may be this is very basic one i.e.
Dear all from the below mentioned table im picking imgurl with this query but
Dear all,Now i have this question in my java program,I think it should be
Hello dear programmers, I am very new to android application development and for practice
Dear stackoveflow, I have this problem. I'm working with an old version of mssql
dear all..i have a table it looks like: Name version DDX 01 DTX 05
Dear All, A newbie to XPATH, I need an xpath to get the HREF

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.