1
Good morning. I’m new to Database and SQL, and I have a question in a college exercise. The objective of the exercise is:
I was able to do the part of presenting the number, description of the account, name of the supplier and locality, but he presents me with all the values and I only want those where the balance sheets do not appear in any invoice but I am not able to do that part. Together sending code
select NúmeroConta, Descrição, Nome, Localidade
from ContasBalanço join Fornecedores
on ContasBalanço.NúmeroConta = Fornecedores.ContaBalançoPredefinida join Facturas
on Fornecedores.IDFornecedor = Facturas.Fornecedor
where
In my opinion, I think the condition that remains to be added is in the Where yet I do not know how to do that part. Together I also leave picture of the tables.
Balance Sheet:
Suppliers:
Invoices:
Itensinvoice:
I’d really appreciate it if someone could help me. As I said, I’m new at this and I’m enjoying learning about databases and I find this interesting, yet this little problem has arisen and I don’t know how to solve it. Regards
Thank you very much for your reply
– IanMoone
I realized that there was an error in my script, so I edited the answer, case test and does not work, please comment here!
– Neto Costa
Your script works, and thank you so much for helping me. I also noticed that a table was missing from the question I put. Balance sheets should only be presented if there is no record in Itensinvoices and not in Invoices. However, I think Itensinvoice is dependent on Invoices. Initially I thought about using your code but replace Invoices with Itensinvoices but soon I realized that I could not because they are dependent. How can I do?
– IanMoone
I edited the reply again, check if now the return is suitable.
– Neto Costa
Already managed to solve. Thank you so much for the help. Just add Left Join Invoices and the condition on...... and it worked. Thank you so much.
– IanMoone