Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite: Selecting the maximum corresponding value

Tags:

select

sqlite

max

I have a table with three columns as follows:

id INTEGER    name TEXT    value REAL

How can I select the value at the maximum id?

like image 349
abidinberkay Avatar asked May 08 '13 08:05

abidinberkay


People also ask

How do I SELECT Max data in SQL?

To find the max value of a column, use the MAX() aggregate function; it takes as its argument the name of the column for which you want to find the maximum value. If you have not specified any other columns in the SELECT clause, the maximum will be calculated for all records in the table.

What is use of SQLite Max aggregate function?

The SQLite MAX function is an aggregate function that returns the maximum value of all values in a group. You can use the MAX function to accomplish a lot of things. For example, you can use the MAX function to find the most expensive products, find the biggest item in its group, etc.

How do you SELECT a row with maximum value?

MySQL select the row with maximum value in a column : MAX() function. This section will help us learn how to get the maximum value for a column and get the record details corresponding to it. Let us start by creating a table sales_details followed by inserting some records to it.

Which query can be used to extract the maximum?

The SQL MAX function is used to return the maximum value of an expression in a SELECT statement.


1 Answers

Get the records with the largest IDs first, then stop after the first record:

SELECT * FROM MyTable ORDER BY id DESC LIMIT 1
like image 128
CL. Avatar answered Nov 10 '22 01:11

CL.