'Select the row with the maximum value of specific column In MySQL using pymysql [duplicate]

I have this table.

id temp hum date
1 20 32 2012
2 37 44 2017

How can I select the max value in temp and it's date? So these two values(37, 2017).I am using PyMySql in python.



Solution 1:[1]

In MySQL 8+ you can use ROW_NUMBER

with cte as 
      (   select *,
                   row_number() over( order by temp desc ) row_num
          from your_table
       ) select id, temp,hum,date
         from cte 
         where row_num=1;

Another solution:

Select id,temp,hum,date
from your_table
order by temp desc limit 1;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ergest Basha