Database? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Database?

If i have a table with the following fields name,Id,balance,date of registration,county and balance how will i select the rows with the maximum and minimum balances only ..by row i mean containing all the 6 fields but only displaying the 2 people with the minimum and maximum balances

12th Jan 2018, 10:08 AM
arnold naftaly
arnold naftaly - avatar
2 Answers
+ 9
Look into MIN() and MAX() functions: https://www.w3schools.com/sql/sql_min_max.asp
12th Jan 2018, 12:33 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
Along with what Shamima mentioned, check for inner joins, since a table can join itself, or another approach would be simple inner queries, (which is another way to inner join), using a where balance equals MIN balance, and salary equals a query in parenthesis that brings the balance where balance equals MAX balance. Just an idea that should work if implemented properly, Good luck Arnold.
12th Jan 2018, 3:36 PM
Roberto Guisarre
Roberto Guisarre - avatar