# SQL Query MAX, MIN and AVG

**URL:** <https://forum.codewithmosh.com/t/sql-query-max-min-and-avg/17582>\
**Category:** SQL\
**Created:** [January 10, 2023, 3:50pm UTC](https://forum.codewithmosh.com/t/sql-query-max-min-and-avg/17582 "2023-01-10T15:50:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naivedya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/naivedya/32/5352_2.png) [@Naivedya](https://forum.codewithmosh.com/u/Naivedya)\
**Post date:** [January 10, 2023, 3:50pm UTC](https://forum.codewithmosh.com/t/sql-query-max-min-and-avg/17582/1 "2023-01-10T15:50:28Z")

</div>

![Screen Shot 2023-01-10 at 9.18.24 PM](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/3/390a57cb4ff4c28fdae3feafd2db211b4e97235b.png)

I seem to be getting an error stating there is LIMIT 0 to 1000 when I apply the MAX or MIN operators. Any idea why this is happening?

This is happening after restoring the database. If anyone has had a similar problem please do let me know.

Cheers,

---

<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 10, 2023, 5:21pm UTC](https://forum.codewithmosh.com/t/sql-query-max-min-and-avg/17582/2 "2023-01-10T17:21:18Z")

</div>

The second last message has nothing to do with your query. You likely opened the `invoices` table in Workbench at 21:14:16 and have automatic row limiting active. Theres a green hook next to the message so everything was fine.

The last message is an error message related to your query. You have a space between `MAX` and the opening parenthesis. Delete that and you’ll be fine.

---

<div class="post-metadata">

**Author:** ![Naivedya](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/naivedya/32/5352_2.png) [@Naivedya](https://forum.codewithmosh.com/u/Naivedya)\
**Post date:** [January 29, 2023, 1:17pm UTC](https://forum.codewithmosh.com/t/sql-query-max-min-and-avg/17582/3 "2023-01-29T13:17:00Z")

</div>

Thanks Sam! Sorry for the delayed response!
