Erro substring sql
SELECT NI.CHV_NFE, NI.COD_ITEM, PROD.NCM_PRODUTO, NI.DESCR_COMPL, NI.QTD, NI.UNID, NI.VL_ITEM, NI.VL_DESC, NI.CST_ICMS, SUBSTRING(CST_ICMS_TABA.CST_ICMS FROM 1 FOR 1) AS CST_ICMS_I, SUBSTRING(CST_ICMS_TABA.CST_ICMS FROM 2 FOR 3) AS CST_ICMS_II, NI.CFOP, NI.ALIQ_ICMS, NI.VL_ICMS, CFOP.CFNOME, CST_ICMS_TABA.DESC_CST, CST_ICMS_TABB.DESC_CST FROM NFE_ITEM NI, PRODUTO PROD, CFOP, CST_ICMS_TABA, CST_ICMS_TABB WHERE NI.COD_ITEM = PROD.COD_PRODUTO AND NI.CFOP = CFOP.CFOP AND CST_ICMS_TABA.COD_CST = CST_ICMS_I AND CST_ICMS_TABB.COD_CST =CST_ICMS_II
Ele da erro:
can't format message 13:794 -- message file C:\Windows\firebird.msg not found.
Dynamic SQL Error.
SQL error code = -206.
Column unknown.
CST_ICMS_I.
At line 22, column 36.
Não consigo arrumar, alguém?
Pablo Ricardo
Curtidas 0
Respostas
Joel Rodrigues
10/12/2014
A coluna CST_ICMS_I não existe. Verifique em sua tabela.
GOSTEI 0
Alex Lekao
10/12/2014
Ola,
Nao sei se entendi mas vc esta CST_ICMS_I para SUBSTRING(CST_ICMS_TABA.CST_ICMS FROM 1 FOR 1) e esta fazendo referencia disso no Where ja esperimentou fazendo referencia a SUBSTRING(CST_ICMS_TABA.CST_ICMS FROM 1 FOR 1) no where no lugar de CST_ICMS_I?
No caso tera que fazer nos dois lugares no where que esta usando o alias que vc criou no select.
nao sei se me fiz entender. rsrsr
Nao sei se entendi mas vc esta CST_ICMS_I para SUBSTRING(CST_ICMS_TABA.CST_ICMS FROM 1 FOR 1) e esta fazendo referencia disso no Where ja esperimentou fazendo referencia a SUBSTRING(CST_ICMS_TABA.CST_ICMS FROM 1 FOR 1) no where no lugar de CST_ICMS_I?
No caso tera que fazer nos dois lugares no where que esta usando o alias que vc criou no select.
nao sei se me fiz entender. rsrsr
GOSTEI 0
Isaac Jose
10/12/2014
vc esta utilzando o sub e renomear o campo mais ele nao existe para fazer a comparação faça como o lekao disse
no seu where faz campo1 = (select com os criterios que vc deseja)
no seu where faz campo1 = (select com os criterios que vc deseja)
GOSTEI 0