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
col_datefield1field2
xyz
abc
xyz
aasdf
sdf
abc
xyz
aasdf
mmn
mmn

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]1-Jun-12[/TD]

[TD="align: right"]85[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]2-Jun-12[/TD]

[TD="align: right"]33[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]3-Jun-12[/TD]

[TD="align: right"]76[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]4-Jun-12[/TD]

[TD="align: right"]84[/TD]

[TD="align: center"]6[/TD]
[TD="align: right"]5-Jun-12[/TD]

[TD="align: right"]85[/TD]

[TD="align: center"]7[/TD]
[TD="align: right"]6-Jun-12[/TD]

[TD="align: right"]84[/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]7-Jun-12[/TD]

[TD="align: right"]84[/TD]

[TD="align: center"]9[/TD]
[TD="align: right"]8-Jun-12[/TD]

[TD="align: right"]11[/TD]

[TD="align: center"]10[/TD]
[TD="align: right"]9-Jun-12[/TD]

[TD="align: right"]85[/TD]

[TD="align: center"]11[/TD]
[TD="align: right"]10-Jun-12[/TD]

[TD="align: right"]84[/TD]

</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
col_datefield1field2
xyz
xyz
mmn
mmn

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]1-Jun-12[/TD]

[TD="align: right"]85[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]7-Jun-12[/TD]

[TD="align: right"]84[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]9-Jun-12[/TD]

[TD="align: right"]85[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"]10-Jun-12[/TD]

[TD="align: right"]84[/TD]

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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,224,267
Messages
6,177,549
Members
452,783
Latest member
back1ply

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