sql - SQL Server 提取状态是否终止,然后不显示该 ID 的先前记录
问题描述
我需要帮助如何编写一个 sql 命令我有几个代理,例如从一月到二月它们是活跃的,三月它们被终止了。如果他们在最后一个日期被终止,那么如何编写查询然后甚至不向我显示该代理的先前记录?
解决方案
如果我理解正确,您需要:
select t.*
from table t
where not exists (select 1 from table t1 where t1.agent = t.agent and t1.status = 'terminated');
推荐阅读
- sql - SQL 日期变量硬编码
- vb.net-2010 - 我想更新 Sql Server 数据库如何在 SQL Server 数据库中添加列或表抛出一个 VB.net 应用程序
- javascript - `Contacts` 中的 prop `Email` 和 'Phone' 标记为必填,但其值为 `undefined`
- html - 覆盖阻止链接
- python - 使用 keras 进行预测时的错误
- javascript - jQuery从选择的循环中获取文本框ID
- c# - 具有基本身份验证的 Twilio C# recordingStatusCallback uri
- python - 将 3D 数组转换为 RGB 值数组
- c - 代码中的 C 编程错误
- javascript - 我怎么能超过33岁!在浏览器中使用 Javascript?