2
I have the following structure
---------------------------------------
|DT_Ven | VLR_CONTA|DT_QUI | VLR_QUI|
|--------------------------------------
|30/07/20| 84,00|NULL | 84,00|
|03/08/20| 100,00|NULL | 100,00|
|04/08/20| 1505,96|04/08/20| 1505,96|
|06/08/20| 10,00|06/08/20| 10,00|
|07/08/20| 50,00|07/08/20| 50,00|
|01/10/20| 350,00|01/10/20| 350,00|
|20/10/20| 200,00|20/10/20| 200,00|
---------------------------------------
I want the field DT_QUI if he is Null bring just like the field DT_Ven like this below.
---------------------------------------
|DT_Ven | VLR_CONTA|DT_QUI | VLR_QUI|
|--------------------------------------
|30/07/20| 84,00|30/07/20| 84,00|
|03/08/20| 100,00|03/08/20| 100,00|
|04/08/20| 1505,96|04/08/20| 1505,96|
---------------------------------------
have tried sql so, more error.
SELECT
CONTAS_PAGAR.DT_VENC,
CONTAS_PAGAR.VLR_CONTA,
CASE
WHEN CONTAS_PAGAR.DT_QUITACAO IS NULL
THEN CONTAS_PAGAR.DT_QUITACAO = CONTAS_PAGAR.DT_VENC
ELSE CONTAS_PAGAR.DT_QUITACAO
END AS DT_QUITACAO,
CONTAS_PAGAR.VLR_QUITACAO
FROM
CONTAS_PAGAR
You did
THEN CONTAS_PAGAR.DT_QUITACAO = CONTAS_PAGAR.DT_VENCshould only beTHEN CONTAS_PAGAR.DT_VENCand in the end rename withAS(alias or nickname)– novic
Its initial field structure is not equal to the columns of the
SQL. In the first table you did not inform that there is the fieldSITUACAO. Could you edit your question.– Tiedt Tech
In place of CASE you can use the COALESCE function:
COALESCE(DT_QUIT, DT_VENC) AS DT_QUITACAO, she serves exactly for this.– anonimo