简体   繁体   中英

How can I take the ids of the registrations with the highest temperature of each day (on a specified period of time)?

Considering I have more than 30 registers/day for that temperature.

  • Name of the table: 'temperatures'
  • Colomn name: 'TempA'

I want one registration for each day, for example:

date: 2015-12-10 12:02 id: 2341 tempa: 54 (which is the highest on that day)
date: 2015-12-09 15:04 id 1923 tempa: 32 (which is the highest on that day)

and so on....

您可以使用max和group by

select max(TempA) from your_table group by day_column
select id from temperatures where TempA=(select max(TempA) from temperatures )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM