请参阅下表:
id ticket_id event
1 130 response
2 130 query
3 130 create
4 130 update
5 131 response
6 131 query
7 131 create
8 132 response
9 132 query
10 132 create
如何在postgres sql 中的事件字段上返回没有"update"(值(的不同ticket_id
例如,它应该返回ticket_id 131和132
谢谢。
您可以使用NOT EXISTS条件:
select distinct t1.ticket_id
from the_table t1
where not exists (select *
from the_table t2
where t2.ticket_id = t1.ticket_id
and t2.event = 'update')