I have a pc, laptop and printer table, each of them having a price and model field.
I want to create a combined view of price and model number from these three tables, sorted by price. I have the following query:
SELECT p.model, p.price FROM (
SELECT price, model FROM laptop
UNION
SELECT price, model FROM pc
UNION
SELECT price, model FROM printer
)
AS p order by p.price desc
Running this query does not sort on price, instead it returns the results sorted on model number. I checked similar question, but unable to make my query sort on price field.
model price
1121 850.0000
1232 350.0000
1232 400.0000
1232 600.0000
1233 600.0000
1233 950.0000
1233 970.0000
1233 980.0000
1260 350.0000
1276 400.0000
1288 400.0000
1298 1050.0000
1298 700.0000
1298 950.0000
1321 970.0000
1401 150.0000
1408 270.0000
1433 270.0000
1434 290.0000
1750 1200.0000
1752 1150.0000