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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:21:56+00:00 2026-05-25T19:21:56+00:00

I want to be able to do this: INSERT INTO TABLE_1(<LIST OF COLUMNS>) SELECT

  • 0

I want to be able to do this:

INSERT INTO TABLE_1(<LIST OF COLUMNS>)
SELECT <LIST OF ROWS> FROM (SELECT DISTINCT <OTHER COLUMNS> FROM TABLE_2);

How can I do this? I receive an error when I try to do it now.

Note that <LIST OF COLUMNS> is the same in both cases I use it, and also not that the fields in <OTHER ROWS> could, but do not necessarily exist in <LIST_OF COLUMNS>.

  • 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-25T19:21:56+00:00Added an answer on May 25, 2026 at 7:21 pm

    OK, a little philosophical treatise here…

    “Distinct” means “reject duplicates”. And to detect duplicated rows you have compare them for equality first.

    If you just compare rows on all columns, everything is fine: two rows are either equal or they are not, there is no third possibility. So you always know whether a row should be rejected as a duplicate or not.

    However, if you try to compare rows by comparing a subset of their columns, you run into trouble: rows that are equal when compared on the subset of their columns may not be equal when compared on all columns. So are they duplicates or not?

    • If you consider them duplicates and reject one of the rows, you’ll also be rejecting values that may not exist in the other row. You are effectively losing data (not to mention that which data you loose is random, so even the data you keep is essentially useless).
    • If you don’t consider them duplicates, then you are not really making them distinct on the column subset, contradicting what you were trying to do in the first place.

    So making rows distinct on the subset of columns can only be done:

    • if you don’t keep the the other columns,
    • or by “merging” values in other columns by subjecting them to aggregate functions such as MAX, COUNT, SUM etc..

    This is the reason why GROUP BY must cover all non-aggregated columns. A DISTINCT is really just a GROUP BY on all columns.

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

Sidebar

Related Questions

I want to be able to list only the directories inside some folder. This
I want to be able to capture images from a webcam on Linux. This
There's this Excel file I want users to be able to download from my
How can I insert a whole bunch of rows into an XML variable without
I want to be able to insert into one table but only if a
I have a table with 4 columns. I want to be able to INSERT
I want to be able to do this. MyInterface interface = new ServiceProxyHelper<ProxyType>(); Here's
Basically I want to be able to do this: session.ExecuteSql(...); I don't need it
I want to be able to set my country of origin - does this
I want to be able to do the Windows equivalent of this Unix/Linux command:

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.