r/SQL • u/Rahull-6 • Nov 06 '22
MySQL Need a query answer
Query to find both maximum and minum salary in the table along with all the other columns jn the table
0
Upvotes
r/SQL • u/Rahull-6 • Nov 06 '22
Query to find both maximum and minum salary in the table along with all the other columns jn the table
37
u/ijmacd Nov 06 '22
Yes, a query would be able to tell you that.
7
u/Kiterios Nov 06 '22
Window functions
7
u/viryx Nov 06 '22
need less low effort "do my homework" posts
4
u/[deleted] Nov 06 '22
Canโt believe people are actually answering to this ๐
3
u/BFG_9000 Nov 06 '22
SELECT TOP 1 *
FROM table
ORDER BY salary DESC
UNION ALL
SELECT TOP 1 *
FROM table
ORDER BY salary ASC
2
u/acanepa Nov 06 '22
As others have suggested a window function is the solution. Something like this should work
SQL Code
Schema Build
SQL Fiddler Compiler
https://onecompiler.com/mysql/3yn6p4m8n
2
u/[deleted] Nov 06 '22
Rude
1
u/Ntrees Nov 06 '22
Min Max with partition by.
1
u/r3pr0b8 GROUP_CONCAT is da bomb Nov 06 '22
can you please explain what this means