clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601504 fiddles created (47955 in the last week).

CREATE TABLE sales ( id serial , saleprice numeric , saledate timestamp , status text ); INSERT INTO sales (saleprice, saledate) VALUES (123, '2012-09-28 02:31') , (123, '2012-09-28 02:31') , (666, '2012-09-28 02:31') -- unique , (123, '2012-09-29 06:36') -- unique , (125, '2012-09-29 02:31') , (125, '2012-09-29 02:31');
6 rows affected
 hidden batch(es)


UPDATE sales s SET status = 'ACTIVE' WHERE NOT EXISTS ( SELECT 1 FROM sales s1 WHERE s1.saleprice = s.saleprice AND s1.saledate = s.saledate -- no dupe AND s1.id <> s.id -- except for row itself );
2 rows affected
 hidden batch(es)


TABLE sales;
id saleprice saledate status
1 123 2012-09-28 02:31:00
2 123 2012-09-28 02:31:00
5 125 2012-09-29 02:31:00
6 125 2012-09-29 02:31:00
3 666 2012-09-28 02:31:00 ACTIVE
4 123 2012-09-29 06:36:00 ACTIVE
 hidden batch(es)