Question: I want to fetch count from table per day but the time column is in long so I can not just simply group by time column. I have to group by date in time column. How can I do this?

Table:

```
Column   |  type
----------------
id       |  Long (bigint)
name     |  String (varchar)
time     |  Long  (bigint)

```

I have try following query but it doesn't work as I have time in long and I want to group by date.

```
select time,count(*) from my_table mt group by time;

```

How can I group by date in above query?

One more thing I'm going to use this query in hibernate so need a query that can also be written in hql.

Answer: 
First of all we will convert our timestamp to date and then group by date!

```
select mt.time,count(*) from my_table mt group by DATE( FROM_UNIXTIME( mt.time ));

```

hoping this will work. cheer :)
```
SELECT DATE(FROM_UNIXTIME(`time`)) AS date_from_time, COUNT(1)
FROM my_table
GROUP BY date_from_time

```