121. Qator taqqoslash (a, b) = (...)
QiyinAvval eng katta summali bitta sotuvni toping. So'ng o'sha sotuv bilan
bir xil (shahar, mahsulot) juftligiga ega barcha sotuvlarni chiqaring
(eng kattasining o'zi ham kiradi).
Buni qator konstruktori bilan yozing:
WHERE (city, product) = (SELECT city, product FROM ... ORDER BY ... LIMIT 1)Ikkita ustunni ikkita alohida ichki so'rov bilan emas, bitta ichki so'rov
bilan taqqoslash shu usulning mohiyati.
Ustunlar: id, city, product, amount.
Saralash: amount kamayish, keyin id o'sish.
sales: id INT PK, city VARCHAR, product VARCHAR, amount NUMERIC(12,2)
Jadval: sales
| Ustun | Turi |
|---|---|
| id | INT PK |
| city | VARCHAR(40) |
| product | VARCHAR(40) |
| amount | NUMERIC(12,2) |
Namuna ma'lumotlar
sample
sales
| idINT | cityVARCHAR(40) | productVARCHAR(40) | amountNUMERIC(12,2) |
|---|---|---|---|
| 4 | Samarqand | Noutbuk | 8700000 |
| 9 | Samarqand | Noutbuk | 1500000 |
| 5 | Samarqand | Smartfon | 3100000 |
| 6 | Buxoro | Noutbuk | 5600000 |
Kutilgan natija
| id | city | amount | product |
|---|---|---|---|
| 4 | Samarqand | 8700000 | Noutbuk |
| 9 | Samarqand | 1500000 | Noutbuk |
sample-full
sales
| idINT | cityVARCHAR(40) | productVARCHAR(40) | amountNUMERIC(12,2) |
|---|---|---|---|
| 1 | Toshkent | Noutbuk | 9800000 |
| 2 | Toshkent | Noutbuk | 4200000 |
| 3 | Toshkent | Smartfon | 3900000 |
| 4 | Samarqand | Noutbuk | 8700000 |
| 5 | Samarqand | Smartfon | 3100000 |
| 6 | Buxoro | Noutbuk | 5600000 |
| 7 | Toshkent | Noutbuk | 7300000 |
| 8 | Buxoro | Smartfon | 2800000 |
| 9 | Samarqand | Noutbuk | 1500000 |
| 10 | Andijon | Muzlatgich | 6400000 |
| 11 | Toshkent | Muzlatgich | 5200000 |
| 12 | Toshkent | Noutbuk | 1100000 |
| 13 | Namangan | Smartfon | 3300000 |
| 14 | Buxoro | Noutbuk | 2700000 |
Kutilgan natija
| id | city | amount | product |
|---|---|---|---|
| 1 | Toshkent | 9800000 | Noutbuk |
| 7 | Toshkent | 7300000 | Noutbuk |
| 2 | Toshkent | 4200000 | Noutbuk |
| 12 | Toshkent | 1100000 | Noutbuk |
sample-extra
sales
| idINT | cityVARCHAR(40) | productVARCHAR(40) | amountNUMERIC(12,2) |
|---|---|---|---|
| 1 | Samarqand | Smartfon | 4474600 |
| 2 | Toshkent | Smartfon | 1100000 |
| 3 | Toshkent | Smartfon | 3751400 |
| 4 | Samarqand | Noutbuk | 8339100 |
| 5 | Buxoro | Muzlatgich | 4235100 |
| 6 | Buxoro | Muzlatgich | 7454304.4 |
| 7 | Buxoro | Noutbuk | 1500000 |
| 8 | Samarqand | Noutbuk | 5600000 |
| 9 | Toshkent | Noutbuk | 3004700 |
| 10 | Toshkent | Noutbuk | 10926300 |
Kutilgan natija
| id | city | amount | product |
|---|---|---|---|
| 10 | Toshkent | 10926300 | Noutbuk |
| 9 | Toshkent | 3004700 | Noutbuk |
O'xshash masalalar
Konsol
Natijani ko'rish uchun so'rovni ishga tushiring.
