Hello, Community!
I need help with the logic of a query I have to do in SQL Server 2012 .
Well, I have three tables: [1 '] operacao_apf
; [2] operacao_contrato
; and, [3] operacao_detalhe
.
What I need to do: in [1 '], I need to get the name of any operation, and, by name, I have to go to [2] and select all contracts related to this operation. After selecting all the contracts in [2] related to the operation searched in 1 , I need to go to [3] and select all the details related to each transaction related to the transaction in 1 .
Layout:
Note that tables are always associated with 1:N
from left to right. An operation can have multiple contracts and each contract can have several details.
What I want to do is generate a report with this, but I need to understand the SQL Server 2012 logic to get started.