title: AWS Athena CAST with GROUP BY
body: <p>I have a table in Athena AWS with a timestamp field. I want to group them by date. My SQL query is:</p>
  
  <p><code>SELECT CAST(createdat AS DATE) FROM conversations GROUP BY createdat</code>
  But my result is the following:
  <a href="https://i.stack.imgur.com/DGYJ4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DGYJ4.png" alt="asd"></a></p>
  
  <p>As you can see the group by does not work, and the reason is that the new table has the name field <code>_col0</code> instead <code>createdat</code>. 
  I also tried:
  <code>SELECT CAST(createdat AS DATE) FROM conversations GROUP BY _col0</code> but I got and error.</p>
  
  <p>Does anybody has any suggestions? I will appreciate it </p>