notin

NOT IN in postgresql not working [closed]

旧巷老猫 提交于 2019-11-28 13:14:49
I am not getting the output as expected, because AND ta.task_status_type_id NOT IN ( 10 ) is not working in below query. SELECT ta.task_id AS id, u.employee_id AS employee_id, ta.task_status_type_id FROM task_assignments AS ta, users AS u WHERE u.id = ta.user_id AND ta.id IN ( SELECT max ( ta.id ) OVER ( partition BY ta.task_id ) AS id FROM task_details AS td, task_assignments AS ta WHERE td.task_id = ta.task_id AND td.developer_employee_id IS NULL AND ta.task_type_id IN(6,7) AND ta.task_status_type_id NOT IN ( 10 ) AND ta.task_status_type_id IN ( 9 ) ); Please help in resolving the error.

NOT IN clause and NULL values

会有一股神秘感。 提交于 2019-11-25 23:57:33
问题 This issue came up when I got different records counts for what I thought were identical queries one using a not in where constraint and the other a left join . The table in the not in constraint had one null value (bad data) which caused that query to return a count of 0 records. I sort of understand why but I could use some help fully grasping the concept. To state it simply, why does query A return a result but B doesn\'t? A: select \'true\' where 3 in (1, 2, 3, null) B: select \'true\'

NOT IN vs NOT EXISTS

别来无恙 提交于 2019-11-25 21:48:02
问题 Which of these queries is the faster? NOT EXISTS: SELECT ProductID, ProductName FROM Northwind..Products p WHERE NOT EXISTS ( SELECT 1 FROM Northwind..[Order Details] od WHERE p.ProductId = od.ProductId) Or NOT IN: SELECT ProductID, ProductName FROM Northwind..Products p WHERE p.ProductID NOT IN ( SELECT ProductID FROM Northwind..[Order Details]) The query execution plan says they both do the same thing. If that is the case, which is the recommended form? This is based on the NorthWind