# abs() vs abs\[\] for fby "while" all() vs all\[\]

**URL:** <https://forum.kx.com/t/abs-vs-abs-for-fby-while-all-vs-all/13924>\
**Category:** Community Support\
**Tags:** imported, kdb-and-q\
**Created:** [May 18, 2024, 12:17pm UTC](https://forum.kx.com/t/abs-vs-abs-for-fby-while-all-vs-all/13924 "2024-05-18T12:17:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dang30.swati](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/dang30.swati/32/128_2.png) [@dang30.swati](https://forum.kx.com/u/dang30.swati)\
**Post date:** [May 18, 2024, 12:17pm UTC](https://forum.kx.com/t/abs-vs-abs-for-fby-while-all-vs-all/13924/1 "2024-05-18T12:17:25Z")

</div>

[https://learninghub.kx.com/forums/topic/abs-vs-abs-for-fby-while-all-vs-all-2](https://learninghub.kx.com/forums/topic/abs-vs-abs-for-fby-while-all-vs-all-2)

May I ask how does abs() differs from abs in a select statement using fby clause?

```
q)tab:([] sym:`g1`g3`g1`g1`g2`g3;price:-2.5 2 -0.5 -0.2 3 4)
q)tab
sym price
---------
g1 -2.5
g3 2
g1 -0.5
g1 -0.2
g2 3
g3 4

q)select from tab where abs(price)=({abs max x};price) fby sym
'type
[0] select from tab where abs(price)=({abs max x};price) fby sym
^
q)
```

and also similarly, in my qsql, if I use all with square brackets, it throws a rank error but all() works fine

```
select from xxx where all[col=`a;col2=`b] //rank error
```

How do I know wher  
Thank you!

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [May 20, 2024, 8:45am UTC](https://forum.kx.com/t/abs-vs-abs-for-fby-while-all-vs-all/13924/2 "2024-05-20T08:45:30Z")

</div>

See these sections of docs on:

- [List Notation](https://code.kx.com/q/basics/syntax/#list-notation)
- [Bracket Notation](https://code.kx.com/q/basics/syntax/#bracket-notation)

Order of evaluation also matters: [Left-of-Right Evaluation](https://code.kx.com/q4m3/4_Operators/#412-left-of-right-evaluation)

```
abs(price)=({abs max x};price)
```

Will run in order:

1. ({abs max x};price)
2. (price)=({abs max x};price)  
3. abs(price)=({abs max x};price)  

whereas:

```
abs[price]=({abs max x};price)
```

Will run in order:

1. ({abs max x};price)  
2. abs[price]  
3. abs[price]=({abs max x};price)  

This tries to pass 2 arguments to **all** which only takes one argument so you get a **rank** error

https://code.kx.com/q/ref/all-any/#all

```
all[col=a;col2=b]
```
