Jump to content
osiel73150

Tnfeestadual Nulo

Recommended Posts

Prezados,

Preciso de uma consulta que traga determinada frase, caso a tabela não exista. alguém pode me ajudar.

SELECT CASE
WHEN TNFEESTADUAL.STATUS = 'C' THEN 'NOTA FISCAL CANCELADA'
WHEN TNFEESTADUAL.STATUS = 'W' THEN 'NOTA FISCAL DENEGADA'
WHEN NOT EXISTS(SELECT IDMOV FROM TNFEESTADUAL) THEN 'SEM VALOR LEGAL'
END
from TNFEESTADUAL
WHERE TNFEESTADUAL.IDMOV ='157864'
AND TNFEESTADUAL.CODCOLIGADA = '1'
A consulta será utilizada para carimbar o DANFE quando este for impresso cancelado ou não autorizado.
desde já agradeço.

Share this post


Link to post
Share on other sites

Tenta assim..

SELECT CASE
WHEN TNFE.STATUS = 'C' THEN 'NOTA FISCAL CANCELADA'
WHEN TNFE.STATUS = 'W' THEN 'NOTA FISCAL DENEGADA'
WHEN TNFE.STATUS IS NULL THEN 'SEM VALOR LEGAL'
END, TNFE.STATUS
FROM TMOV T
LEFT JOIN TNFEESTADUAL TNFE ON T.IDMOV = TNFE.IDMOV
AND T.CODCOLIGADA = TNFE.CODCOLIGADA
WHERE T.IDMOV ='157864'
AND T.CODCOLIGADA = '1'

Share this post


Link to post
Share on other sites

Tenta assim..

SELECT CASE
WHEN TNFE.STATUS = 'C' THEN 'NOTA FISCAL CANCELADA'
WHEN TNFE.STATUS = 'W' THEN 'NOTA FISCAL DENEGADA'
WHEN TNFE.STATUS IS NULL THEN 'SEM VALOR LEGAL'
END, TNFE.STATUS
FROM TMOV T
LEFT JOIN TNFEESTADUAL TNFE ON T.IDMOV = TNFE.IDMOV
AND T.CODCOLIGADA = TNFE.CODCOLIGADA
WHERE T.IDMOV ='157864'
AND T.CODCOLIGADA = '1'

Puxa Vida!! Perfeito!!!

obrigado.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.