Re: [SQL] SQL conversion help

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: [SQL] SQL conversion help
Дата
Msg-id ofu0ik$qo$1@blaine.gmane.org
обсуждение исходный текст
Ответ на [SQL] SQL conversion help  (Ertan Küçükoğlu <ertan.kucukoglu@1nar.com.tr>)
Список pgsql-sql
Ertan Küçükoğlu schrieb am 20.05.2017 um 06:01:
> I have below SQL script used in SQL Server. I would like some help to
> convert it into PostgreSQL format, please.
> 
> DECLARE @satirno INT 
> SET @satirno = 0
> UPDATE urtrecetedet
> SET @satirno = satirno = @satirno + 1
> WHERE recetekodu = 'ASD'

Assuming your primary key column is named ID, you can do it like this:

update urtrecetedet u set satirno = t.rn
from (   select id,          row_number() over (order by id) as rn  from urtrecetedet  where recetekodu = 'ASD'
) t 
where t.id = u.id;





В списке pgsql-sql по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: [SQL] SQL conversion help
Следующее
От: Sebastien FLAESCH
Дата:
Сообщение: [SQL] TRUNCATE TABLE corrupts pg_class.relfilenode = pg_attrdef.pg_attrdef