GUJ Discussões   :   últimos tópicos   |   categorias   |   GUJ Respostas

Dúvida Join - Query Oracle to SQL Server

sqlserver
oracle
query
Tags: #<Tag:0x00007f9d295e15c8> #<Tag:0x00007f9d295e1190> #<Tag:0x00007f9d295e0808>

#1

Boa Tarde,

Como posso converter abaixo para SQL Server:

SELECT count(*)
FROM sis_colunas scdm,
gen_dominio_campo dcpo,
gen_dominio domi,
tbg_instrucao inst,
gen_label_idioma lbli,
gen_form_bloco_cpo bcpo
WHERE scdm.id_coluna (+) = dcpo.id_coluna
AND dcpo.id_dominio_campo (+) = bcpo.id_dominio_campo
AND domi.id_dominio (+) = bcpo.id_dominio
AND inst.id_instrucao (+) = bcpo.id_instrucao
AND lbli.id_label (+) = bcpo.id_label
AND lbli.id_idioma (+) = 1
AND bcpo.id_form_bloco =1
ORDER BY bcpo.fg_chave DESC, bcpo.nr_sequencia;

Tentei assim, mas o resultado está diferente:

SELECT count(*) FROM sis_colunas scdm right outer join gen_dominio_campo dcpo on scdm.id_coluna = dcpo.id_coluna right outer join gen_form_bloco_cpo bcpo on dcpo.id_dominio_campo = bcpo.id_dominio_campo right outer join gen_dominio domi on domi.id_dominio = bcpo.id_dominio right outer join tbg_instrucao inst on inst.id_instrucao = bcpo.id_instrucao right outer join gen_label_idioma lbli on lbli.id_label = bcpo.id_label right outer join gen_label_idioma lbli2 on lbli2.id_idioma = 1 AND bcpo.id_form_bloco = 1 ORDER BY bcpo.fg_chave DESC, bcpo.nr_sequencia;

Obrigado,


#2

Usa Left Join.

https://www.w3schools.com/sql/sql_join_left.asp