Need help in constructing a SQL query to get results as shown in the example below.
Table0
AO FD VL
BK AC 01
BK BU XX
BD AC 01
BD BX NNN
Table1
US PR
U1 A
U2 X
Table2
PR AT AO
A B BK
A C BD
X D BK
Table3
AT AO FD VL
B BK AC 01
B BK BU XY
B BK BU XX
C BD AC 01
C BD BX XXX
D BK AC 02
D BK BU XY
Table0 contains the criteria which is to be used to get the data from Table1, Table2 and Table3.
I am trying to construct a single SQL query using the 4 tables get the following result:
US PR AT AO FD VL
U1 A B BK AC 01
U1 A B BK BU XX
---------------
The following row should should not appear since it matches only one row in Table0 and not both the rows for column AO.
U1 A C BD AC 01
I know I will need to use grouping to get the result, I cant seem to be able to get the required result.
Thanks in advance.
Table0
AO FD VL
BK AC 01
BK BU XX
BD AC 01
BD BX NNN
Table1
US PR
U1 A
U2 X
Table2
PR AT AO
A B BK
A C BD
X D BK
Table3
AT AO FD VL
B BK AC 01
B BK BU XY
B BK BU XX
C BD AC 01
C BD BX XXX
D BK AC 02
D BK BU XY
Table0 contains the criteria which is to be used to get the data from Table1, Table2 and Table3.
I am trying to construct a single SQL query using the 4 tables get the following result:
US PR AT AO FD VL
U1 A B BK AC 01
U1 A B BK BU XX
---------------
The following row should should not appear since it matches only one row in Table0 and not both the rows for column AO.
U1 A C BD AC 01
I know I will need to use grouping to get the result, I cant seem to be able to get the required result.
Thanks in advance.