Wednesday, 15 February 2012

sql - how to get latest datetime from multiple same dates in mysql -



sql - how to get latest datetime from multiple same dates in mysql -

how latest datetime multiple same dates in mysql?

select start_time times start_time between '2013-01-27' , '2013-02-02' order start_time

this outputs:

2013-01-27 00:00:00 2013-01-28 09:00:00 2013-01-29 00:00:00 2013-01-30 09:00:00 2013-01-31 00:00:00 2013-02-01 09:00:00 2013-02-01 21:00:00 2013-02-02 00:00:00

i want output except want latest datetime 2013-02-01 output this:

2013-01-27 00:00:00 2013-01-28 09:00:00 2013-01-29 00:00:00 2013-01-30 09:00:00 2013-01-31 00:00:00 2013-02-01 21:00:00 <<<<<<<< 2013-02-02 00:00:00

select max(start_time) times start_time between '2013-01-27 00:00:00' , '2013-02-02 23:59:59' grouping date(start_time) order start_time sqlfiddle demo

mysql sql group-by

No comments:

Post a Comment