CREATE SEQUENCE tablename_colname_seq;
alter TABLE "Виплата" alter column "Код" type integer NOT NULL DEFAULT nextval('tablename_colname_seq');
ALTER SEQUENCE tablename_colname_seq OWNED BY "Виплата"."Код";
UPDATE table_name SET column4 = CASE
when column4 = 'minus' then column2 - lead(column2) OVER (ORDER BY id)
else column4
END
SELECT id,
(SELECT COUNT(id) FROM table1 WHERE model_id = t1.id) as 'Таблица №1',
(SELECT COUNT(id) FROM table2 WHERE model_id = t1.id) as 'Таблица №2'
FROM table1 as t1
WHERE id = 781;
OR vchar4 LIKE "%searchtext%"