I have searched for this but couldn't find any answer on this particular matter. For my Databases class we have to make a demonstration of the use of some SQL functions on a database we have created. One of those functions is MIN(), while the other is MAX(), among others.
What's happening to me is that when running the command SELECT nome AS mais_barato FROM equipamento HAVING MIN(preço);
(names are in portuguese: nome=name, mais_barato=cheaper, equipamento=equipment, preço=price) the output is the following:
+-------------+
| mais_barato |
+-------------+
| ZON Hub |
+-------------+
Where one would expect (the original table is further bellow, for you to see for yourselves what would be expected):
+-------------+
| mais_barato |
+-------------+
| Modem |
+-------------+
What is wrong in the statement? When running the SELECT nome AS mais_caro FROM equipamento HAVING MAX(preço);
(mais_caro=more_expensive) the output is the same as the one using MIN(preço)
.
The original table equipamento
is (cod is the unique code associated with the equipments):
+-----+----------+--------+
| cod | nome | preço |
+-----+----------+--------+
| 152 | ZON Hub | 120 |
| 228 | PowerBox | 100 |
| 444 | Fibra | 200 |
| 673 | NetGear | 70 |
| 779 | Modem | 50 |
+-----+----------+--------+
I am using mysql Ver 14.14 Distrib 5.5.34, for debian-linux-gnu (i686) using readline 6.2
on Ubuntu 13.10
Thank you very much