简体   繁体   English

SQL 查询过滤器按修改日期

[英]SQL query filter by modified date

I beg your pardon for my English in advance.提前请您原谅我的英语。

I have this data:我有这个数据:

数据

I need to get the max process for the OP column in a given Start_date .我需要在给定的Start_date中获取OP列的最大进程。

That should look like this:这应该是这样的:

结果

I can't get that, any help would be appreciated我无法得到那个,任何帮助将不胜感激

Toad is often used with Oracle, so I'll use Oracle syntax. Toad 经常与 Oracle 一起使用,所以我将使用 Oracle 语法。 You can adapt for other databases.您可以适应其他数据库。 The key is extracting the date from start_date .关键是从start_date中提取日期。

select t.*
from (select t.*,
             row_number() over (partition by trunc(start_date) order by start_date desc) as seqnum
      from t
     ) t
where seqnum = 1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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