CREATE TABLE test(id INTEGER, val VARCHAR(10)); BEGIN; INSERT INTO test VALUES(1, 'a'), (1, 'b'), (2, 'a'); SAVEPOINT x; INSERT INTO test VALUES(3, 'b'), (4, 'a'), (4, 'b'), (5, 'b'); SAVEPOINT y; DELETE FROM test WHERE id = 1; ROLLBACK TO x; DELETE FROM test where id = 4; COMMIT;
CREATE TABLE test (id INTEGER, x INTEGER, y INTEGER); INSERT INTO test VALUES(1, 1, 2); INSERT INTO test VALUES(2, 1, 4); INSERT INTO test VALUES(3, 1, 6); INSERT INTO test VALUES(4, 1, 8); INSERT INTO test VALUES(5, 2, 3); INSERT INTO test VALUES(6, 2, 5); INSERT INTO test VALUES(7, 2, 7); INSERT INTO test VALUES(8, 2, null); SELECT count(*), count(y), sum(y), avg(y) FROM test WHERE x > 1;