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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:41:42+00:00 2026-05-15T17:41:42+00:00

I have a table that I need to normalize with many fields In SQL-Server

  • 0

I have a table that I need to normalize with many fields In SQL-Server 2000.
It contains 2 fields which I’m using to come up with distinct combination as defined by the specs.
ID and Rate: there are multiple rows of same IDs and Rates

I first created a temp table by grouping the IDs and Rates combination.

SELECT ID, Count(*) AS IDCounts, SUM(RATE) As Total 
INTO #Temp
GROUP BY ID

Now I use Distinct to find only the unique combinations. So i’ll have multiple ID groups sharing same Total and IDCounts

SELECT DISTINCT Total, IDCounts
INTO #uniques
FROM #Temp

Now my question is how to join a single ID back to that distinct grouping of IDCounts and Total and put that into a new table? It doesn’t matter which one of the IDs in the groups as long as I use one from the same grouping.

  • 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-15T17:41:43+00:00Added an answer on May 15, 2026 at 5:41 pm

    Keeping your temp tables (although this could all be done in a single query):

    SELECT ID, Count(*) AS IDCounts, SUM(RATE) As Total 
    INTO #Temp
    GROUP BY ID
    
    SELECT Total, IDCounts, MIN(ID) AS SomeID
    INTO #uniques
    FROM #Temp
    GROUP BY Total, IDCounts
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Not sure if it will suit your situation, but you… May 16, 2026 at 4:58 pm
  • Editorial Team
    Editorial Team added an answer I think I've found the source of the problem. The… May 16, 2026 at 4:58 pm
  • Editorial Team
    Editorial Team added an answer NULL cannot be compared using equal or CASE WHEN. Use… May 16, 2026 at 4:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a table that's been created by a module. I need to include
I have a small database that I need help designing. I have a VB.NET
I have a table that has 5 columns: AcctId (int), Address1 (varchar), Address2 (varchar),
I have a database design that's normalized well enough, but now I need to
I need some help with a mySQL statement. I've got a mySQL table that
in my stored procedure I have a table variable contains rows ID. The are
I have a table that currently is a long list of devices and information
I have a table that looks something like this: ID | GROUP ------------------- 1000001
I have a table that looks like this: Id PageId Key Content LastUpdated ---------------------------------------------
I have a table that has about 400,000+ rows. I am writing some pattern

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.