Suppose I have a SQL database in which a column could look something like this
Numbers
-------
1
1
2
3
4
4
Is it possible to create a single SQL query that simply grabs the largest number, which in this case would be 4? Or would I have to query every single number, put them in some sort of list in an external program, and write an algorithm to find the largest one?
Use can use the MAX Aggregate function. Since your table only has one column it would look like
depending on your backend you could also put into a variable. For example in SQL Server
Here’s a working example on data.stackexchange.com
If you also wanted the Max Per somthing you’d need a group by
For example this query on Data.SE gives the max score per tag