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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:34:19+00:00 2026-06-07T23:34:19+00:00

I have a issue where I need to combine a bunch of duplicate data.

  • 0

I have a issue where I need to combine a bunch of duplicate data. I’m starting with a table that was merged from two different sources. An example of the data would be:

aID, bID, value1, value2, value3, value4

The issue is that there are situations where aID match bID but only one of the other fields are filled in:

1, 1, samedata, null, null, 1
1, 1, samedata, red, null, null
1, 1, samedata, null, htmldata, null

I’m looking for a way to display the entire row of data but roll up all the values that are not null so that there is one line per matching id. I’ve been trying Group By and Group_Concat but haven’t found the secret sauce yet.

The 1 row I would want from the example above would be:

1, 1, samedata, red, htmldata, 1

Any ideas?

  • 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-07T23:34:21+00:00Added an answer on June 7, 2026 at 11:34 pm

    One trick is to use MAX or MIN, since those will prefer a non-null value over a null one:

    SELECT aID,
           bID,
           MAX(value1) AS value1,
           MAX(value2) AS value2,
           MAX(value3) AS value3,
           MAX(value4) AS value4
      FROM ...
     GROUP
        BY aID,
           bID
    ;
    

    (When I use MAX for this purpose, I usually include a comment noting this, since it’s not instantly obvious to the casual reader.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data from two spreadsheets where I need to compare the quantities of
We have an issue where we need to modify keys for users that are
So here's my issue. I have an image that I need to shrink. The
We have got two distinct lists of users that we need to power logged
I have multiple app processes that each connect to servers and receive data from
I need to combine two color values from two WriteableBitmap objects and compute something
I rarely use SQL and have a unique issue I need to solve. I
I have an issue with a my SQL query. I need to execute a
I have searched for this but nobody have the same issue.. Now I need
I need to override styles for two EditText instances. I have two issues regarding

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.