i need particular group query. have list of events (title, start, end) fields event title, number, first , last event rows grouping title , subsequent start-end datetime little slack (example 15 minutes).
for example:
create table events( id int auto_increment, title varchar(50), start datetime, end datetime ); insert events values ('title1','2013-07-15 12.00','2013-07-15 13.00'), ('title2','2013-07-15 12.00','2013-07-15 13.00'), ('title1','2013-07-15 13.15','2013-07-15 14.15'), ('title1','2013-07-15 14.30','2013-07-15 15.30'), ('title1','2013-07-15 19.00','2013-07-15 21.00');
the result should be:
'title1', 3, '2013-07-15 12.00','2013-07-15 15.30' 'title2', 1, '2013-07-15 12.00','2013-07-15 12.00' 'title1', 1, '2013-07-15 19.00','2013-07-15 19.00' (not susequent [+/- 15min] first group)
is possibile? thank you.
no, sql isn't flexible unfortunately.
you need either stored procedure or doing full select , resolving problem on application level.
Comments
Post a Comment