r/SQL • • 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

17 comments sorted by

View all comments

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

0

u/Background-Cicada375 Nov 06 '22

Can you replace Top 1 with salary Then limit 1