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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:55:51+00:00 2026-05-25T20:55:51+00:00

Been having trouble with this for some time. I have a database sort of

  • 0

Been having trouble with this for some time.

I have a database sort of like this:

Car_ID   Car_Brand   Car_Model   Car_Price
   1     Ford        Fiesta       4000
   2     Ford        Mustang     29000
   3     Ford        Focus       12000
   4     Honda       Civic       15000
   6     Honda       Jazz         5000
   7     Toyota      Prius       14000

I want to perform a search that finds the cheapest car then orders the rest of the cars of the same brand by price ascending.

I want my output to be this:

Car_ID   Car_Brand   Car_Model   Car_Price
   1     Ford        Fiesta       4000
   3     Ford        Focus       12000
   2     Ford        Mustang     29000
   6     Honda       Jazz         5000
   4     Honda       Civic       15000
   7     Toyota      Prius       14000

The cheapest car is the Ford Fiesta so that and the rest of the Ford models follow it directly ordered by price. Honda then has the second cheapest model so the Jazz and the rest of the Hondas follow and so on.

Is this possible?

  • 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-25T20:55:52+00:00Added an answer on May 25, 2026 at 8:55 pm

    What you need to do is create a transient data set that contains car_brand and the lowest price for that brand (which I’ll call brand_price), then JOIN that data back to your original cars table. This will give you the additional piece of information (brand_price) that you need to sort the data:

     SELECT car_id, car_brand, car_model, price FROM cars C1
        JOIN (select car_brand, MIN(price) AS brand_price FROM cars GROUP BY car_brand) C2
          ON C1.car_brand = C2.car_brand
        ORDER BY C2.brand_price, C1.car_brand, C1.price
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have been having trouble with this for a while now. I have
No doubt elements of this question have been asked before, but I'm having trouble
I have been having some trouble with reminders as of lately. I was wondering
I've been having some trouble with Xcode. Every time I launch my application, it
I have been looking into android development for some time and would really like
Been having some trouble implementing a single-column index in LaTeX. I've been employing the
I've been having some trouble with vs2008 SP1 running in debug mode when I
I've been reading through Programming Clojure, and I've been having some trouble understanding Stuarts
I having trouble in dividing the HTML frames. I have been using the following
Ive been having some trouble using Plot to graph a complicated composite function. I

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.