How can I select and display value of that field in a row of a table whose value is maximum or minimum ?
For example, say I have the following table structure for balance
.
+------+-------+--------+
| id | bal | userid |
+------+-------+--------+
| 1 | 4.00 | 1 |
| 2 | 8.35 | 2 |
| 3 | 15.67 | 3 |
| 4 | 10.00 | 4 |
+------+-------+--------+
Here, I want to show the users with maximum balance and minimum balance. What should be my query to pick show them? Like here in this case user 3 has maximum balance and user 1 has minimum. I want to pick them and LEFT JOIN them with my members
table using mem_id
to extract their username mem_uname
and show their balance.