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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:38:34+00:00 2026-05-19T02:38:34+00:00

I have a table in my SQL database that looks like: id type radius

  • 0

I have a table in my SQL database that looks like:

id    type      radius
-------------------------
1     type1     0.25
2     type2     0.59
3     type1     0.26
4     type1     0.78
5     type3     0.12
6     type2     0.45
7     type3     0.22
8     type3     0.98

I am having trouble figuring out how to define a SELECT query which returns the lowest radius for each type.

In other words, the results I am looking for would be:

Results:

id    type      radius
-------------------------
1     type1     0.25
6     type2     0.45
7     type3     0.22

I assume I use ORDER BY to order the radius from lowest to highest and grab the lowest. However, I also assume I need to use DISTINCT on the type, but I can’t figure out how to pull this off.

Any expert SQL’ers out there have any idea of this type of SELECT query is possible? Any help is much appreciated!

Many thanks,
Brett

  • 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-19T02:38:34+00:00Added an answer on May 19, 2026 at 2:38 am

    You want to group by type, and then get the minimal radius from that type, and sort it by type

    SELECT type, MIN(radius) FROM table
    GROUP BY type
    ORDER BY type
    

    If you want the id to go with the min, you cannot do it as I first typed: that id is a semi-random Id for type. Sadly, you’ll have to settle for (from the top of my head)

    SELECT t1.id,t1.type,t1.radius FROM table t1 
    WHERE radius = ( 
         SELECT MIN(radius) FROM table
         WHERE radius = t1.radius
       )
    

    (final edit: you’ve got to test that last one, basic warning is that in the first query you cannot reliably fetch the Id, because it will NOT belong specifically to the type that has the lowest radius)

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

Sidebar

Related Questions

I have a table in my MySQL database that looks like the following banner
I have data in my database that looks like this: Date (DateTime) Type (varchar)
I have a table in the database that I'm retrieving using LINQ to SQL,
I have a table in a SQL Server 2005 database with a trigger that
I have a listings database. I also have a listings_attributes database that looks like
Hi say of have a table of cars in my SQL database. That table
In a SQL server database, I have a table which contains a TEXT field
Lets say I have a table in a sql server 2000 database called TransactionType:
I have a field (say, foo) in a table in a SQL Server database
I have a SQL Mobile database with one table. It has several columns with

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.