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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:23:09+00:00 2026-06-14T09:23:09+00:00

Here is the problem: CREATE TABLE #datesX ( [Name] [varchar] (8) NULL , [MarriedDate]

  • 0

Here is the problem:

CREATE TABLE #datesX
    (
    [Name] [varchar] (8) NULL
    , [MarriedDate] datetime NULL
    , [HappyScoreX] [int] NULL
    ) 
INSERT INTO #datesX 
    values 
     ('TIM', null, 20),
     ('RAJ', '01 jan 2012', 20),
     ('PAUL', '01 jan 1960', 20)


CREATE TABLE #datesY
    (
    [Name] [varchar] (8) NULL
    , [FirstSprogDate] datetime NULL
    , [HappyScoreY] [int] NULL
    ) 
INSERT INTO #datesY 
    values 
     ('TIM', '01 jan 1995', 20),
     ('RAJ', '20 JUN 2013', 20),
     ('JASE', null, 20),
     ('PAUL', '01 jan 1970', 20)


CREATE TABLE #datesZ
    (
    [Name] [varchar] (8) NULL
    , [FoundGodDate] datetime NULL
    , [HappyScoreZ] [int] NULL
    ) 
INSERT INTO #datesZ 
    values 
     ('TIM', null, 20),
     ('RAJ', null, 20),
     ('JASE', '01 DEC 2012', 20),
     ('PAUL', '01 jan 1970', 20)




SELECT 
        [Name] = COALESCE(x.Name, y.Name, z.Name), 
        x.[MarriedDate],
        y.[FirstSprogDate],
        z.[FoundGodDate],
        [HappyScoreX] = SUM(ISNULL(x.[HappyScoreX],0.0)),
        [HappyScoreY] = SUM(ISNULL(y.[HappyScoreY],0.0)),
        [HappyScoreZ] = SUM(ISNULL(z.[HappyScoreZ],0.0))
FROM 
        #datesX x
        FULL OUTER JOIN #datesY y ON
                x.Name = y.Name 
        FULL OUTER JOIN #datesZ z ON
                x.Name = z.Name 
GROUP BY
        COALESCE(x.Name, y.Name, z.Name), 
        x.[MarriedDate],
        y.[FirstSprogDate],
        z.[FoundGodDate]

I can sort of see why the record for JASE is being duplicated – how do I amend the query so that JASE only has one record ?

  • 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-14T09:23:10+00:00Added an answer on June 14, 2026 at 9:23 am

    Try this join instead:

    FULL OUTER JOIN #datesY y ON
           x.Name = y.Name 
    FULL OUTER JOIN #datesZ z ON
           coalesce(x.Name, y.name) = z.Name 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

INSERT INTO table is producing a NULL value for the returned recordset. I'm trying
Structure: CREATE TABLE `links` ( `id` int(11) NOT NULL auto_increment, `title` int(11) default NULL,
I am trying to create(successful), insert(problem here) and select(just to check i i am
Here i create table in database dynamically. User enters name as his wish and
I'm running into an issue casting a VARCHAR in one table into a DATETIME
Here is my problem: Create a constructor for a telephone number given a string
OK, here is how to re-create the problem had: Create a new project, using
I am trying to create a simple drawing game like DrawSomething. The problem here
I'm having a hard time trying to create a XmlRepository. The problem here I
Here is the problem details: 1) I want to create dynamic (ip based) download

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.