All Pls help me writing SQL for the following scenario
Table 1
COL1
Table 2
COL1
COL2 ----> FK to TAB1.COL1 (1 to many)
COL3
COL4
COL5
COL6
Table 3 Is a cross reference table (For a given TAB2.COL1 there may be many TAB4.COL1 values)
COL1 -------> Foreign key to TAB2.COL1
COL2 -------> Foreign Key to TAB4.COL1
Table 4
COL1
COL2
COL3
COL4
COL5
COL6
Now the requirement is for a given TAB1.COL1 I need to find out the count of TAB2.COL3 <> TAB4.COL3
TAB2.COL4 <> TAB4.COL4
TAB2.COL5 <> TAB4.COL5
TAB2.COL6 <> TAB4.COL6
In One query The output should be something like
COUNT(COL3) = 1
COUNT(COL4) = 1
COUNT(COL5) = 1
COUNT(COL6) = 1
Table 1
COL1
Table 2
COL1
COL2 ----> FK to TAB1.COL1 (1 to many)
COL3
COL4
COL5
COL6
Table 3 Is a cross reference table (For a given TAB2.COL1 there may be many TAB4.COL1 values)
COL1 -------> Foreign key to TAB2.COL1
COL2 -------> Foreign Key to TAB4.COL1
Table 4
COL1
COL2
COL3
COL4
COL5
COL6
Now the requirement is for a given TAB1.COL1 I need to find out the count of TAB2.COL3 <> TAB4.COL3
TAB2.COL4 <> TAB4.COL4
TAB2.COL5 <> TAB4.COL5
TAB2.COL6 <> TAB4.COL6
In One query The output should be something like
COUNT(COL3) = 1
COUNT(COL4) = 1
COUNT(COL5) = 1
COUNT(COL6) = 1
Comment