M
M
Muranx2021-09-14 08:34:55
SQL
Muranx, 2021-09-14 08:34:55

How in this case to get access to the table?

Hello! There is the following SQLrequest:

SELECT model, p FROM
(
   SELECT model, max(price) AS p
   FROM laptop
   GROUP BY model
   UNION
   SELECT model, max(price)
   FROM pc
   GROUP BY model
   UNION
   SELECT model, max(price)
   FROM printer
   GROUP BY model
) AS matherial

as a result it returns a table :
model | p
1121 | 850.0000
1232 | 600.0000
1233 | 980.0000
1260 | 350.0000
1276 | 400.0000
1288 | 400.0000
1298 | 1050.0000
1321 | 970.0000
1401 | 150.0000
1408 | 270.0000
1433 | 270.0000
1434 | 290.0000
1750 | 1200.0000
1752 | 1150.0000
My task is to select from this table modelwith the maximum price ... I tried to get it using
... AS matherial WHERE p IN (SELECT max(p) FROM matherial)
But apparently, the skuel interpreter does not see this matherial table at the WHERE execution stage, tell me pliz how can I display the model, by the way, the MODEL, without the price

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question