Here is what i am trying to do. Original table with composite key Erow and Irow.
Columns
Erow Irow 1 2 3 4 5 6
115 141
116 142
117 143
117 144
118 145
119 146
120 147
122 148
123 148
125 151
126 152
127 153
130 157
131 157
132 157
133 160
134 157
.
..
154 167
155 167
156 167
I run a query to get all rows where irow occurs more than once
SELECT *
FROM Table
WHERE IRow In (
Select IRow From Table Group By IRow Having
count(IRow) > 1
) Order By ERow,IRow
which gives me this:
Erow Irow 1 2 3 4 5 6
122 149
123 149
130 157
131 157
132 157
134 157
154 167
155 167
156 167
Now there is another table, call it Table2 Which has Erow as it's primary key
RowNumber t1 t2 t3 t4 t5 ........
.
..
122 9074
123 9074
.
..
130 8830
131 8832
132 8832
134 8831
.
..
154 9830
155 9832
156 9832
Now Since RowNumber 122 and 123 have the same value in column t4 i.e. 9074 and 131 and 132 have the same value i.e. 8832 and since row 155 and 156 have the same value i.e. 9832, i want to exclude those rows from the original result of table. Rows 154, 155 and 156 are an exception since if i exclude two of those rows i.e. 155 and 156, that leaves only 154 which has the same irow, and hence i want to exclude that as well. So essentially in words I want "all rows from table where Irow occurs more than once and where column t4 in table2 referenced by Erow of those Irow's are not the same and should not include the exception mentioned above where after excluding all duplicate t4's for a particular set of Erow's leaves only one row"
Hence my result of the original query should only be:
Erow Irow 1 2 3 4 5 6
130 156
134 156
I would really appreciate someone's help in writing a query for this.
thanks in advance
Columns
Erow Irow 1 2 3 4 5 6
115 141
116 142
117 143
117 144
118 145
119 146
120 147
122 148
123 148
125 151
126 152
127 153
130 157
131 157
132 157
133 160
134 157
.
..
154 167
155 167
156 167
I run a query to get all rows where irow occurs more than once
SELECT *
FROM Table
WHERE IRow In (
Select IRow From Table Group By IRow Having
count(IRow) > 1
) Order By ERow,IRow
which gives me this:
Erow Irow 1 2 3 4 5 6
122 149
123 149
130 157
131 157
132 157
134 157
154 167
155 167
156 167
Now there is another table, call it Table2 Which has Erow as it's primary key
RowNumber t1 t2 t3 t4 t5 ........
.
..
122 9074
123 9074
.
..
130 8830
131 8832
132 8832
134 8831
.
..
154 9830
155 9832
156 9832
Now Since RowNumber 122 and 123 have the same value in column t4 i.e. 9074 and 131 and 132 have the same value i.e. 8832 and since row 155 and 156 have the same value i.e. 9832, i want to exclude those rows from the original result of table. Rows 154, 155 and 156 are an exception since if i exclude two of those rows i.e. 155 and 156, that leaves only 154 which has the same irow, and hence i want to exclude that as well. So essentially in words I want "all rows from table where Irow occurs more than once and where column t4 in table2 referenced by Erow of those Irow's are not the same and should not include the exception mentioned above where after excluding all duplicate t4's for a particular set of Erow's leaves only one row"
Hence my result of the original query should only be:
Erow Irow 1 2 3 4 5 6
130 156
134 156
I would really appreciate someone's help in writing a query for this.
thanks in advance