I have a database that looks like this
users
phone created
8001234578 1540231160
9001234578 1540220360
1001234578 1540144760
2001234578 1540058360
Note that the created column is a unix timestamp.
I want to group them by users created on the same day with a count of users, so the above example database should return something like this.
[
{day: '10/22/2018', count: 2},
{day: '10/21/2018', count: 1},
{day: '10/20/2018', count: 1},
]
I tried learning about the to_char command but I couldn't figure it out, this is what I tried:
SELECT
to_char(created, 'Day') as day,
COUNT(*) as count
FROM users
WHERE created >= ${startDate} AND created <= ${endDate}
GROUP BY to_char(created, 'Day')
It returned this:
[{day: ' .ay', count: '4'}]
dateortimestampcolumn in youruserstable, so how would you know on which day they were created?