Hi,
I am trying to build join query on Bank_Fees, Unit_Lookup, and Fee_Lookup tables:
Bank_Fees
The result of the query I am trying to receive would be like this:
Query for Invoice_Mnth = 3 and Invoice_Yr = 2013
I built a query that lists missing Unit-4 only, and just once, one record, and lists Unit-3, total three records:
but how to add the rest of the units and also list fee types with NULL amounts, I have no clue.
I am sure it can be done, but my SQL experience is quite limited...
Thank you for any help!
I am trying to build join query on Bank_Fees, Unit_Lookup, and Fee_Lookup tables:
Bank_Fees
Code:
Invoice_Mnth Invoice_Yr Unit_Name Fee_Type Amt
1 2013 Unit-1 A 12
1 2013 Unit-1 A 18
1 2013 Unit-1 B 13
1 2013 Unit-1 B 15
1 2013 Unit-2 A 10
1 2013 Unit-2 B 11
2 2013 Unit-3 A 5
2 2013 Unit-3 A 7
3 2013 Unit-3 A 6
3 2013 Unit-3 B 9
3 2013 Unit-3 B 4
...
Code:
[u]Unit_Lookup[/u]
Unit_Name
Unit-1
Unit-2
Unit-3
Unit-4
...
Code:
[u]Fee_Lookup[/u]
Fee_Type
A
B
C
The result of the query I am trying to receive would be like this:
Query for Invoice_Mnth = 3 and Invoice_Yr = 2013
Code:
[u]Unit_Name Fee_Type Amt[/u]
Unit-1 A NULL
Unit-1 B NULL
Unit-1 C NULL
Unit-2 A NULL
Unit-2 B NULL
Unit-2 C NULL
Unit-4 A NULL
Unit-4 B NULL
Unit-4 C NULL
Unit-3 A SUM(6)
Unit-3 B SUM(9,4)
Unit-3 C NULL
I built a query that lists missing Unit-4 only, and just once, one record, and lists Unit-3, total three records:
Code:
Unit-4 NULL NULL
Unit-3 A SUM(6)
Unit-3 B SUM(9,4)
but how to add the rest of the units and also list fee types with NULL amounts, I have no clue.
I am sure it can be done, but my SQL experience is quite limited...
Thank you for any help!