Been getting challenge with this for a while.

I've got a database kind of such as 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 wish to try a search that finds the least expensive vehicle then orders the relaxation from the cars of the identical brand by cost climbing.

I would like my output to become 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 least expensive vehicle may be the Ford Fiesta to ensure that and also the relaxation from the Ford models abide by it directly purchased by cost. Honda then has got the second least expensive model therefore the Jazz and also the relaxation from the Hondas follow and so forth.

Is possible?

What you ought to do is produce a transient data set that consists of vehicle_logo and the cheapest cost for your brand (which I'll call brand_cost), then JOIN that data to your original cars table. This provides you with the extra bit of information (brand_cost) you need to sort the information:

 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

Something similar to this will work:

SELECT a.*
FROM Cars a
  LEFT JOIN (
    SELECT Car_Brand, MIN(Car_Price) AS MinPrice
    FROM Cars
    GROUP BY Car_Brand
  ) b ON a.Car_Brand = b.Car_Brand
ORDER BY b.MinPrice, a.Car_Price

I'd perform a min arranged by Vehicle_Brand order through the min cost after which perform a join purchased through the sorted vehicle_logo and cost. I'll find out if I'm able to obtain the query accomplished for this.

I believe you'll have the ability to do this using the following query

SELECT Car_ID, Car_Brand, Car_Model, Car_Price 
FROM tblcars
ORDER BY Car_Price, Car_Brand

unless of course I skipped something

select * from cars order by  Car_Price, Car_Brand ASC