learning_grexcel
Active Member
- Joined
- Jan 29, 2011
- Messages
- 319
Excel 2007
<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
In the above table, I want to list all the field1 which has corresponding field2 values both 85 and 84
I want output like below. As you can see here the field1 values have both 85 and 84 corresponding code.
Excel 2007
<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
I tried the below query but it lists all field1 which exists either 85 or 84 but I want to list all field1 which has both 85 and 84.
A | B | C | |
---|---|---|---|
1 | col_date | field1 | field2 |
2 | 1-Jun-12 | xyz | 85 |
3 | 2-Jun-12 | abc | 33 |
4 | 3-Jun-12 | xyz | 76 |
5 | 4-Jun-12 | aasdf | 84 |
6 | 5-Jun-12 | sdf | 85 |
7 | 6-Jun-12 | abc | 84 |
8 | 7-Jun-12 | xyz | 84 |
9 | 8-Jun-12 | aasdf | 11 |
10 | 9-Jun-12 | mmn | 85 |
11 | 10-Jun-12 | mmn | 84 |
<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1
In the above table, I want to list all the field1 which has corresponding field2 values both 85 and 84
I want output like below. As you can see here the field1 values have both 85 and 84 corresponding code.
Excel 2007
A | B | C | |
---|---|---|---|
1 | col_date | field1 | field2 |
2 | 1-Jun-12 | xyz | 85 |
3 | 7-Jun-12 | xyz | 84 |
4 | 9-Jun-12 | mmn | 85 |
5 | 10-Jun-12 | mmn | 84 |
<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet2
I tried the below query but it lists all field1 which exists either 85 or 84 but I want to list all field1 which has both 85 and 84.
Code:
select col_date, field1, field2 from table1
where field2 = '85' or field2 = '84'