Reputation: 1753
I have a table in which one of the column is timestamp and I have the following query
SELECT * FROM test WHERE (timepacket BETWEEN 2014-02-16 00:00:00 and 2014-02-19 00:00:00) AND (shift = 1)
But this query gives me all the rows between the date range given in sql query. Thus my question is how can group the results from above query according to dates. Like
2014-02-16
1st row
2nd row
3rd row
2014-02-17
1st row
2nd row
3rd row
4th row
and so on
Upvotes: 0
Views: 71
Reputation: 6854
Even your query is not much clear but as per my understanding you want to do ordering based on date, if it is then use below query-
SELECT * FROM test WHERE (timepacket BETWEEN 2014-02-16 00:00:00 and 2014-02-19 00:00:00) AND shift = 1 order by date(timepacket);
Upvotes: 0
Reputation: 13484
Use GROUP BY or Order by
SELECT * FROM test WHERE (timepacket BETWEEN 2014-02-16 00:00:00 and 2014-02-19 00:00:00)
AND (shift = 1) GROUP BY timepacket
Upvotes: 0
Reputation: 4888
SELECT * FROM test WHERE
timepacket BETWEEN '2014-02-16 00:00:00' AND '2014-02-19 00:00:00'
AND shift = 1
GROUP BY timepacket;
Upvotes: 0