Skip to content

Instantly share code, notes, and snippets.

@primogf
Created April 7, 2017 20:05
Show Gist options
  • Save primogf/4cffc3fa8b5f16dadfadfe72f46304f1 to your computer and use it in GitHub Desktop.
Save primogf/4cffc3fa8b5f16dadfadfe72f46304f1 to your computer and use it in GitHub Desktop.
update Document set stat = 0 where id_documento in (
select id_documento from (
select
d.id_documento
from
DocumentOrigin o
inner join Document d on d.id_documento = o.id_documento
where
o.id_registro in(
SELECT
o.id_registro
FROM
Document d
INNER JOIN
DocumentOrigin o ON o.id_documento = d.id_documento
WHERE
d.stat <> 0 and id_registro > 128263
group by o.id_registro
having Count(*) > 1
) and d.caminho_file is null) as view
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment