title: Group by Error when using DATE() or Trun()
body: <p>I am trying to get the count of appointments on a given day, on a given ServiceResource. Each of these values are stored in different tables requiring me to use joins. The code I am using is below:</p>
  <pre><code>select
  trunc(s.actualstarttime) &quot;Delivery Date&quot;,
  s2.name &quot;Van Name&quot;, 
  count(a.serviceid) &quot;Stops&quot;
  from
  assignedresource a
  join serviceappointment s on s.id = a.serviceid
  inner join serviceresource s2 on s2.id = a.serviceid
  where
  s.status = 'Completed'  and
  s.actualstarttime &gt; '2021-12-20 00:00:00' and s.actualstarttime &lt; '2021-12-23 23:00:00'
  group by 1, 2
  order by
  actualstarttime desc;
  </code></pre>
  <p>My expected output should give me a table like this:</p>
  <p>2021-12-23 | Van A  | 3</p>
  <p>2021-12-23 | Van B  | 4</p>
  <p>2021-12-22 | Van A  | 5</p>
  <p>But I keep getting this error :
  <em>SQL Error [500310] [42803]: Amazon Invalid operation: column &quot;s.actualstarttime&quot; must appear in the GROUP BY clause or be used in an aggregate function;</em></p>
  <p>I have tried using
  <code>group by trunc(s.actualstarttime), s2.name</code> as well. Can someone help me figure out why or how can I get around this?</p>