# How to use Select with conditions?

**URL:** <https://community.wolfram.com/t/how-to-use-select-with-conditions/20866>\
**Category:** Questions\
**Created:** [October 13, 2022, 12:55pm UTC](https://community.wolfram.com/t/how-to-use-select-with-conditions/20866 "2022-10-13T12:55:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhenyuzeng](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zhenyuzeng](https://community.wolfram.com/u/zhenyuzeng)\
**Post date:** [October 13, 2022, 12:55pm UTC](https://community.wolfram.com/t/how-to-use-select-with-conditions/20866/1 "2022-10-13T12:55:47Z")

</div>

Hello,  
I am trying to use `Select` to select something meeting my requirements. For example:

```
Select[{{1, 2, 3}, {4, 1, 6}}, Abs[#3 - #2] > 3 &]

```

I hope this can select lists in which `Abs[#3-#2]>3`, such as `{4,1,6}`.  
But I see the code above does not work rightly. Where did I wrong and what is the right code?

---

<div class="post-metadata">

**Author:** ![ahmed](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ahmed/32/5858_2.png) [@ahmed](https://community.wolfram.com/u/ahmed)\
**Post date:** [October 13, 2022, 1:54pm UTC](https://community.wolfram.com/t/how-to-use-select-with-conditions/20866/2 "2022-10-13T13:54:25Z")

</div>

You need to use [Part](https://reference.wolfram.com/language/ref/Part.html) in this case

```
Select[{{1, 2, 3}, {4, 1, 6}}, Abs[#[[3]] - #[[2]]] > 3 &]

```

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [October 13, 2022, 2:08pm UTC](https://community.wolfram.com/t/how-to-use-select-with-conditions/20866/3 "2022-10-13T14:08:44Z")

</div>

You could also use `Cases`

```
Cases[{{1, 2, 3}, {4, 1, 6}}, {_, x_, y_} /; Abs[y - x] > 3]

```

---

<div class="post-metadata">

**Author:** ![zhenyuzeng](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zhenyuzeng](https://community.wolfram.com/u/zhenyuzeng)\
**Post date:** [October 13, 2022, 2:09pm UTC](https://community.wolfram.com/t/how-to-use-select-with-conditions/20866/4 "2022-10-13T14:09:29Z")

</div>

Yes, I just can’t image this way myself. When you pointed it out, I can understand. Thanks.

---

<div class="post-metadata">

**Author:** ![zhenyuzeng](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zhenyuzeng](https://community.wolfram.com/u/zhenyuzeng)\
**Post date:** [October 13, 2022, 2:10pm UTC](https://community.wolfram.com/t/how-to-use-select-with-conditions/20866/5 "2022-10-13T14:10:12Z")

</div>

Good way. `Cases` is more vivid. Thanks.
