SQL-选择用日期取消的进程
我有一个表格,显示进程的状态(特别是我搜索取消的进程),没有排序。我想再次选择他们中的所有人。我想这样做“将特定日期粘贴到已取消的流程,并检查在取消状态之后是否还有其他状态 例如: [id][moddate][status]SQL-选择用日期取消的进程,sql,oracle,Sql,Oracle,我有一个表格,显示进程的状态(特别是我搜索取消的进程),没有排序。我想再次选择他们中的所有人。我想这样做“将特定日期粘贴到已取消的流程,并检查在取消状态之后是否还有其他状态 例如: [id][moddate][status] 2017年1月1日开始 1 2017年1月2日等待签字 2017年1月04日取消 1 2017年1月09日交货单据 1 2017年11月1日完成的一种方法是使用窗口功能: select d.* from (select d.*, max(case
2017年1月1日开始
1 2017年1月2日等待签字
2017年1月04日取消
1 2017年1月09日交货单据
1 2017年11月1日完成的一种方法是使用窗口功能:
select d.*
from (select d.*,
max(case when status = 'canceled' then applicationdate end) over (partition by id) as canceldate
from database
where applicationdate between date '2017-01-01' and date '2017-07-24'
) d
where applicationdate > canceldate;
mysql还是(MS)SQL Server?@Jens SQLDeveloper@Matt…我认为SQL developer与Oracle有关联。
select d.*
from (select d.*,
max(case when status = 'canceled' then applicationdate end) over (partition by id) as canceldate
from database
where applicationdate between date '2017-01-01' and date '2017-07-24'
) d
where applicationdate > canceldate;