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

  • Home
  • SEARCH
  • 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 7458321
In Process

The Archive Base Latest Questions

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

I have a problem with this SQL Grouping. If i have a table with

  • 0

I have a problem with this SQL Grouping.

If i have a table with 3 columns. Key is a unique key for every record. Type is the type of record and Version is the version of the type.

ID    Type      Version
------------------------
1      A          200
2      A          100
3      B          200
4      B          200
5      B          100

I need to get 1 row for each version of each type

so it would look something like

ID    Type       Version
------------------------
1      A           200
2      A           100
3      B           200
5      B           100

I know I need to group by the Type and version but I cant seem to figure out how to get the unique key for each Type and Version since they are on the same table

SELECT Type, Version FROM TableName GROUP BY Type, Version 

Gets me all the unique Types and Versions, but I cant figure out how to finish off the query.

  • 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-29T13:25:57+00:00Added an answer on May 29, 2026 at 1:25 pm

    you mean the unique ID?
    you need to use an aggregation function like MAX, MIN, SUM, AVG

    you cant get an unique value. Think about it, if you have:

    1   A   100
    2   A   100
    3   A   100
    

    you want only one row with

    A 100

    but whats the logic to define the ID between 1,2 and 3? It isnt unique. That’s why you need a MAX or MIN or any other aggregation function

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

Sidebar

Related Questions

I seem to have a problem with this SQL query: SELECT * FROM appts
I have a problem with an SQL query on Postgresql. This select clause is
I have a problem in my select statement in my query. This sql query
I have a very simple grouping and aggregation problem in LINQ to SQL that
I have a problem constructing a mysql query: I have this table tSubscribers were
I have this problem. I first connect(log) to SQL Server using SQL Management Studio
I have this problem regarding sql which i will be using in a webservice
HI, I have a problem with this query SELECT * FROM table WHERE `name`
I have this problem. Given a users table that consists of users' username in
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE

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.