title: Knex Aggregates (Min, Max)
body: <p>I have an application built using react, express, and PostgreSQL. I have used knex to create and seed the tables in SQL - now I am trying to display aggregate data (min, max, count, etc). However, every time I try to create a new function i get this error <em><strong>select * from &quot;growthstocks&quot; where &quot;stock_id&quot; = $1 limit $2 - invalid input syntax for type integer: &quot;max&quot;</strong></em></p>
  <p>My table &quot;growthstocks&quot; is as follows</p>
  <pre><code>table.increments(&quot;stock_id&quot;).primary(); // sets stock_id as the primary key
        table.string(&quot;ticker&quot;);
        table.string(&quot;name&quot;);
        table.integer(&quot;price&quot;);
        table.integer(&quot;marketcap&quot;);
  </code></pre>
  <p>Back End</p>
  <p>growth.service.js</p>
  <pre><code>function max(){
    return knex(&quot;growthstocks&quot;).max(&quot;price&quot;)
  }
  </code></pre>
  <p>growth.controller.js</p>
  <pre><code>async function max(req, res){
    res.json({data:await growthstocksService.max()})
  }
  }
  </code></pre>
  <p>growth.router.js</p>
  <pre><code>router.route(&quot;/max&quot;).get(controller.max).all(methodNotAllowed)
  }
  </code></pre>