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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:59:25+00:00 2026-06-06T11:59:25+00:00

I am trying to merge the data from two tables into one result but

  • 0

I am trying to merge the data from two tables into one result but without duplicating id’s in the CourseID with the user’s completions taking precedence in the results.

User Course Completion Table

Col Name        | Default | PK?
===================================
UserID                      Y
CourseID                    Y
SystemComplete    NULL      N
UserComplete      NULL      N

UserID, CourseID, SystemComplete, UserComplete
1, 1, NULL, 12/06/2012
1, 2, NULL, 12/06/2012
1, 3, 10/06/2012, 12/06/2012
1, 4, NULL, NULL
1, 5, 10/06/2012, NULL
2, 1, NULL, 12/06/2012

Course to Group table

Col Name        | Default | PK?
===================================
CourseID                     Y
GroupID                      Y

CourseID, GroupID
1, 1
2, 1
3, 1
4, 1
12, 1
5, 2
6, 2

Expected results

I want to find all of the course completions for a user and supplement that list with the uncompleted items. For example, if I want the list for Group 1 and User 1, I would get

CourseID, SystemComplete, UserComplete
======================================
1, NULL, 12/06/2012
2, NULL, 12/06/2012
3, 10/06/2012, 12/06/2012
4, NULL, NULL
12, NULL, NULL --not in completion record

What I’ve tried

I have tried several queries but I can’t seem to figure this out. The one below was something I found in several questions.

SELECT
  COALESCE(uc.CourseID, cg.CourseID) as CourseID
FROM
  CoursesToGroup as cg
FULL JOIN UserCompletion as uc ON
  uc.CourseID = cg.CourseId
WHERE
  uc.UserID = 1 AND
  cg.GroupID = 1

…but this only returns a one row result

The closest I have gotten is UNIONing two queries but then I can’t figure out how to get the UserComplete and SystemComplete data into the query

SELECT CourseID
FROM UserCompletion
WHERE
  EmployeeID = 1

UNION

SELECT CourseID
FROM CoursesToGroup
WHERE
  LearningPathID = 1

This one will return the proper results for the CourseID but, as I stated previously, I can’t figure out how to drop the completion data in there and still remove duplicate CourseId.

What am I missing here?

  • 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-06T11:59:27+00:00Added an answer on June 6, 2026 at 11:59 am
    SELECT CourseID, SystemComplete, UserComplete
    FROM UserCompletion
    WHERE
    UserId = 1
    
    UNION
    
    SELECT CourseId, null, null
    FROM CoursesToGroup
    where GroupId = 1
    and CourseId NOT IN 
        (SELECT CourseId From UserCompletion
         WHERE UserId = 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to merge two docx-documents into one docx-document using OpenXML SDK 2.0. The
Trying to merge two tables, but I can't really get my head around it.
I'm trying to pass post data from one page to the next but PreviousPage
I am trying to merge some columns from one table into a view that
I am trying to merge two data.frames together, based on a common column name
I'm trying to merge two file that have the same structure, and some data
I'm trying to merge some data but beyond the basics I get a bit
Basically I'm trying to combine two tables together into a new table. The first
I have two datasets each with one data table pulled from different sources and
I'm trying to figure out how to migrate data from one cassandra cluster, to

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.