我需要帮助如何写一个sql命令我有几个代理,例如从Jan到feb他们是活跃的,并在三月他们被终止。如果查询在最后一个日期被终止,那么如何编写查询然后不显示该代理的先前记录?
如果我理解正确你需要:
select t.* from table t where not exists (select 1 from table t1 where t1.agent = t.agent and t1.status = 'terminated');