1
Good morning Personal.
I am very beginner with SQL and need to do the following query, but Bigquery has error: Name Cnpj_radical not found Inside A at [3:6]
Why can’t I call the JOIN ON alias?
SELECT FORMAT(LPAD(A.CNPJ,8,'0')) as CNPJ_radical, A.DEBITO , A.CCF , A.PROTESTO , A.QTD, A.FLAG_RESTRICAO, B.porte
FROM `analytics-eda-0186.qualidade_de_dados.FLAG_RESTRICAO_PJ_202010` as A
INNER JOIN `data-3660.dados_views.v_TB_DADOS_ABERTOS_CNPJ_MES10`as B
ON A.CNPJ_radical = substr(B.numero_de_inscricao , 1 , 8)
Because the filter occurs before the
SELECT
. Soon your fieldCNPJ_rapical
is only computed after searching the filtered data by DBMS.– Bruno Warmling