'pl sql how can i fetch records with max values from another column by each room number
table
| room-number | entry-number | electricity |
|---|---|---|
| n100 | 5 | 100 |
| n100 | 4 | 90 |
| n200 | 2 | 75 |
| n200 | 1 | 69 |
| n300 | 6 | 150 |
| n300 | 5 | 111 |
result should be
| room-number | electricity |
|---|---|
| n100 | 100 |
| n200 | 75 |
| n300 | 150 |
Solution 1:[1]
I'm not sure because I haven't tried it but
try this.
SELECT room-number, MAX(electricity) FROM table group by room-number
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jinyoung So |
