How to relate these tables, returning specific values?

0

[Firebird] sgbd - IBExpert

I need to know how I can relate these two tables (comment below), so that I get the following results:

TABLE: CONTARECEBER

  • DTDOCUMENTO (date you entered the system)
  • DTVENCIMENTO (date the document will expire)
  • SPREAD (date of document cancellation)
  • STATUS (document canceled status)
  • CODCONTARECEBER (document code)

TABLE: COUNTERFEITING

  • CODECARECEBERQUITACAO (document discharge code, if any)
  • DTQUITACAO (Date the document was removed, if any)

These are the ones I need to display, they're in two tables, I tried to use LEFT JOIN on my command, but it's not working, I thought I might be doing something wrong too.

select 
    contareceber.dtdocumento,
    contareceber.dtvencimento,
    contareceber.dtcancelamento,
    contareceber.stcancelada,
    contareceber.codcontareceber,
    contareceber.codorganizacao,
    contareceberquitacao.dtquitacao,
    contareceberquitacao.codcontareceberquitacao
from contareceber
   left join contareceberquitacao on (contareceber.codcontareceberquitacao = contareceberquitacao.codcontareceberquitacao)
where (contareceber.dtdocumento between '01.01.2015' and '31.12.2015') and (contareceber.codorganizacao = '001')
    
asked by anonymous 01.06.2017 / 15:54

0 answers