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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:31:34+00:00 2026-06-13T20:31:34+00:00

I get join 2 tables but use 3 table. I need not duplicate values.

  • 0

I get join 2 tables but use 3 table. I need not duplicate values. But I try join have duplicate.

Table peopleAll:

pNo    pName
-------------
00001  Sang
00002  Janta
00003  Els
00004  Est
00005  Sam
00006  John
00007  Misan
00008  Wila
00009  light
00010  Smith
00011  Ritpo

Table fTime:

cNo    cDate                     cIn                        cOut
-----------------------------------------------------------------------------------
00001  2012-10-22 00:00:00.000   2012-10-22 07:59:00.000    2012-10-22 20:34:00.000
00002  2012-10-22 00:00:00.000   2012-10-22 12:50:00.000    2012-10-22 19:50:00.000
00003  2012-10-22 00:00:00.000   2012-10-22 12:01:00.000    2012-10-22 20:30:00.000
00004  2012-10-22 00:00:00.000   2012-10-22 07:55:00.000    2012-10-22 20:30:00.000
00005  2012-10-22 00:00:00.000   2012-10-22 07:27:00.000    2012-10-22 20:31:00.000
00010  2012-10-22 00:00:00.000   2012-10-22 07:12:00.000    2012-10-22 20:22:00.000

Table Leave:

lNo    lDate                     lStart                     lStop
-----------------------------------------------------------------------------------
00002  2012-10-22 00:00:00.000   2012-10-22 08:00:00.000    2012-10-22 12:00:00.000
00003  2012-10-22 00:00:00.000   2012-10-22 08:00:00.000    2012-10-22 12:00:00.000
00011  2012-10-22 00:00:00.000   NULL                       NULL

This SQL code:

SELECT lr.lNo, lr.lDate, lr.lStart, lr.lStop 
FROM Leave lr 
Where lr.cStart = '2012-10-22'

UNION ALL

SELECT pa.pNo, ISNULL(tf.cDate, Convert(nvarchar(10),'2012-10-22',114)),tf.cIn, tf.cOut
FROM fTime tf FULL OUTER join peopleAll pa On tf.cNo = pa.pNo AND 
tf.cDate = Convert(nvarchar(10),'2012-10-22',114)

returns this output:

lNo    lDate                     lStart                     lStop
-----------------------------------------------------------------------------------
00001  2012-10-22 00:00:00.000   2012-10-22 07:59:00.000    2012-10-22 20:34:00.000
00002  2012-10-22 00:00:00.000   2012-10-22 08:00:00.000    2012-10-22 12:00:00.000
00002  2012-10-22 00:00:00.000   2012-10-22 12:50:00.000    2012-10-22 19:50:00.000
00003  2012-10-22 00:00:00.000   2012-10-22 08:00:00.000    2012-10-22 12:00:00.000
00003  2012-10-22 00:00:00.000   2012-10-22 12:01:00.000    2012-10-22 20:30:00.000
00004  2012-10-22 00:00:00.000   2012-10-22 07:55:00.000    2012-10-22 20:30:00.000
00005  2012-10-22 00:00:00.000   2012-10-22 07:27:00.000    2012-10-22 20:31:00.000
00006  2012-10-22 00:00:00.000   NULL                       NULL
00007  2012-10-22 00:00:00.000   NULL                       NULL
00008  2012-10-22 00:00:00.000   NULL                       NULL
00009  2012-10-22 00:00:00.000   NULL                       NULL
00010  2012-10-22 00:00:00.000   2012-10-22 07:12:00.000    2012-10-22 20:22:00.000
00011  2012-10-22 00:00:00.000   NULL                       NULL

I try to change FULL OUTER JOIN then LEFT OUTER JOIN and I get output:

lNo    lDate                     lStart                     lStop
-----------------------------------------------------------------------------------
00002  2012-10-22 00:00:00.000   2012-10-22 08:00:00.000    2012-10-22 12:00:00.000
00002  2012-10-22 00:00:00.000   2012-10-22 12:50:00.000    2012-10-22 19:50:00.000
00003  2012-10-22 00:00:00.000   2012-10-22 08:00:00.000    2012-10-22 12:00:00.000
00003  2012-10-22 00:00:00.000   2012-10-22 12:01:00.000    2012-10-22 20:30:00.000
00004  2012-10-22 00:00:00.000   2012-10-22 07:55:00.000    2012-10-22 20:30:00.000
00007  2012-10-22 00:00:00.000   NULL                       NULL
00008  2012-10-22 00:00:00.000   NULL                       NULL
00010  2012-10-22 00:00:00.000   2012-10-22 07:12:00.000    2012-10-22 20:22:00.000
00011  2012-10-22 00:00:00.000   NULL                       NULL

LEFT OUTER join have miss some field??

I need this output:

lNo    lDate                     lStart                     lStop
-----------------------------------------------------------------------------------
00001  2012-10-22 00:00:00.000   2012-10-22 07:59:00.000    2012-10-22 20:34:00.000
00002  2012-10-22 00:00:00.000   2012-10-22 12:50:00.000    2012-10-22 19:50:00.000 
00003  2012-10-22 00:00:00.000   2012-10-22 12:01:00.000    2012-10-22 20:30:00.000
00004  2012-10-22 00:00:00.000   2012-10-22 07:55:00.000    2012-10-22 20:30:00.000
00005  2012-10-22 00:00:00.000   2012-10-22 07:27:00.000    2012-10-22 20:31:00.000
00006  2012-10-22 00:00:00.000   NULL                       NULL
00007  2012-10-22 00:00:00.000   NULL                       NULL
00008  2012-10-22 00:00:00.000   NULL                       NULL
00009  2012-10-22 00:00:00.000   NULL                       NULL
00010  2012-10-22 00:00:00.000   2012-10-22 07:12:00.000    2012-10-22 20:22:00.000
00011  2012-10-22 00:00:00.000   NULL                       NULL

(00002,00003 from fTime)

Please help me. Thanks you for you time. 🙂

  • 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-13T20:31:35+00:00Added an answer on June 13, 2026 at 8:31 pm
    Select p.pNo
    ,Coalesce(l.cDate,t.lDate,'2012-10-22') as ldate
    ,Coalesce(l.lStart,t.cIn) as lstart
    ,Coalesce(l.lStop,t.cOut  ) as lstop
    from peopleall p
    left join leave l on l.lNo=p.Pno and l.ldate='2012-10-22'
    left join fTime t on t.tNo=p.Pno and t.cDate='2012-10-22'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to join two tables (below) which i get. But then I want
I need help regarding JOIN tables to get category name & author name from
I have a 3 tables that I'm trying to join and get distinct results.
I have two tables that I need to join... I want to join table1
i'm trying to join 3 tables together but use an IF statment to only
I'm trying to LEFT JOIN two tables, to get a list of all rows
Consider i am using join on three tables to get a desired result-set... Now
Actually if i am doing INNER JOIN of two tables then i will get
I want to join my CHEESE table with FRESHNESS to get CHEESE and FRESHNESS
I have some SQL I need to get working on SQL 2005/2008. The SQL

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.