list a field value on base of other field using ms access query

learning_grexcel

Active Member
Joined
Jan 29, 2011
Messages
319
Excel 2007
ABC
1col_datefield1field2
21-Jun-12xyz85
32-Jun-12abc33
43-Jun-12xyz76
54-Jun-12aasdf84
65-Jun-12sdf85
76-Jun-12abc84
87-Jun-12xyz84
98-Jun-12aasdf11
109-Jun-12mmn85
1110-Jun-12mmn84

<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
ABC
1col_datefield1field2
21-Jun-12xyz85
37-Jun-12xyz84
49-Jun-12mmn85
510-Jun-12mmn84

<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'
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
lose the single quotes if field2 is numeric
replace the single quotes with double quotes if field2 is character
 
Upvote 0
Yes it is text data/type. I tried with double quotes also, but it is still the same. It returns all values where field2 is '85' or field2 = '84' but I'm looking for output where field1 has both code '84' and '85'.
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,358
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top