Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement construction

Status
Not open for further replies.

mm0000

IS-IT--Management
May 19, 2002
295
IN
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.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top