# Order by client\_id does not work

**URL:** <https://forum.codewithmosh.com/t/order-by-client-id-does-not-work/1726>\
**Category:** SQL\
**Created:** [January 7, 2021, 6:12am UTC](https://forum.codewithmosh.com/t/order-by-client-id-does-not-work/1726 "2021-01-07T06:12:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravi](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@Ravi](https://forum.codewithmosh.com/u/Ravi)\
**Post date:** [January 7, 2021, 6:12am UTC](https://forum.codewithmosh.com/t/order-by-client-id-does-not-work/1726/1 "2021-01-07T06:12:05Z")

</div>

I’m trying order by client\_id but it not working, can someone help me with this.

select \*  
from invoices i  
where invoice\_total\>(  
select avg(invoice\_total)  
from invoices  
where i.client\_id=client\_id  
)

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [January 7, 2021, 6:28am UTC](https://forum.codewithmosh.com/t/order-by-client-id-does-not-work/1726/2 "2021-01-07T06:28:58Z")

</div>

Just append `order by client_id` to your query.
