sql - 如何根据psql中一条记录的值排除具有相同ID的所有行?

标签 sql postgresql

enter image description here

假设我有上面的结果,并且想要排除 ID 为 14010497 的所有行,因为至少其中一行的日期为 2/25。我将如何过滤它?使用 WHERE table.end_date > '2019-02-25' 仍会包含日期为 2-23 的行

最佳答案

尝试这样的事情:

  select * from your_table
  where id not in (
     select distinct id
     from your_table
     where end_date > '2019-02-25'
     )
  /

关于sql - 如何根据psql中一条记录的值排除具有相同ID的所有行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55462487/

相关文章:

sql - 可为空的外键与公共(public)父键

mysql - sql '->>' 运算符出错

Postgresql 条件和

postgresql - 当 RDS Postgres DB 被删除时,它是否清除连接的 Redis Elasticache?

postgresql - postgresql 中预计算用户定义函数

mysql - 错误代码 : 1215. 无法添加外键约束

SQL 标量值函数返回 Null

sql - 在 Microsoft SQL Server 2005 中模拟 group_concat MySQL 函数?

c# - 如何处理 NLog 的所有事件属性布局渲染器生成的空值?

sql - Postgresql 从多个表中删除多行