6
I have the following query:
CREATE
OR REPLACE FORCE VIEW "Resumo_vendas" (
"TIPO_REGISTRO"
,"VLR_DESCONTOS"
,"VLR_ACRESCIMOS"
,"VLR_PIS"
,"VLR_COFINS"
,"VLR_ICMS"
,"DTA_EMISSAO_NOTA"
) AS (
SELECT 1 AS tipo_registro
,m01am AS vlr_descontos
,m01by AS vlr_acrescimos
,m01cia AS vlr_pis
,m01cib AS vlr_cofins
,m01cic AS vlr_icms
,NULL AS dta_emissao_nota FROM tabela1 t01
)
UNION ALL
(
SELECT 45 AS tipo_registro
,m45am AS vlr_descontos
,m45by AS vlr_acrescimos
,m45cia AS vlr_pis
,m45cib AS vlr_cofins
,m45cic AS vlr_icms
,M45xa AS dta_emissao_nota FROM tabela45 t45
);
My problem is: Tabela1 does not have the columns "VLR_PIS", "VLR_COFINS" and "VLR_ICMS" and in table45 yes. Is there any way I can create this View without deleting these columns?
If such columns do not exist in your
tabela1
What values do you want to consider in this case? It is not just replace the field name with the value to be considered? For example.0 AS VLR_PIS
in place ofm01cia AS vlr_pis
.– anonimo
In reality, table 45 is a continuation of table 1, but these fields only started to have value from table 45. So in table 1 these fields didn’t even exist. I will try to use this 0 AS VLR_PIS
– hmSantos