Left Join in SQL

3
SELECT SUM(TAXAS) FROM DOCUMENTO
LEFT JOIN PARCELAS PARCELA IN
(PARCELA.CODE = DOCUMENTO.CODE)
WHERE PARCELAS.FATURADAS = TRUE

I'm getting a syntax error that I can not resolve

    
asked by anonymous 17.04.2018 / 19:03

2 answers

4
SELECT SUM(DOC.TAXAS) FROM DOCUMENTOS DOC
LEFT JOIN PARCELAS PARCELA ON
(PARCELA.CODE = DOC.CODE)
WHERE PARCELAS.FATURADAS = 1

You put IN when it should be ON and should be 1 instead of true This from where I had not noticed, then you can give Ricardo's answer as correct

    
17.04.2018 / 19:03
4

You have two errors in your script:

1) LEFT JOIN PARCELAS PARCELA IN should be: LEFT JOIN PARCELAS PARCELA ON

Documentation: link

2) WHERE PARCELAS.FATURADAS = TRUE should be: WHERE PARCELAS.FATURADAS = 1

bit fields are compared to 0 (false) or 1 (true)

    
17.04.2018 / 19:08