mysql - how to get the count ONLY in a specific time period -
i need count of vehicles appear more 10times/ week showing between '2012-07-24' , '2012-09-02' , . tried :
select distinct * anpr_in location='a35.1.ob.1' , date(time) between '2012-07-24'and '2012-09-02' group plate having count(plate)>10;
but doesnt filter cars still appear out of period.
the table looks like:
plate location number time t971jur a3024.7.ib.1 96 2012-05-13 18:06:17 hn52ywe a3024.13.ob.1 94 2012-05-13 18:09:53 r179nbm a335.6.ob.1 90 2012-05-13 18:08:55 wv07eax a35.1.ib.1 91 2012-05-13 18:05:09 hf02nfh a334.14.ib.1 94 2012-05-13 18:06:43 hk11bhe a33.5.ib.2 96 2012-05-13 18:07:52 39341 a35.1.ob.1 0 2012-05-13 18:08:09 cp61pcz a35.1.ib.1 96 2012-05-13 18:07:04 lm06ukn a3024.8.ib.1 96 2012-05-13 18:06:44 3b001 a35.1.ob.1 0 2012-05-13 18:07:49 wg10yct a3024.13.ob.1 90 2012-05-13 18:08:04 hy60xte a3024.8.ib.1 93 2012-05-13 18:05:31 m397bla a334.14.ob.1 92 2012-05-13 18:06:57
this should return count of plates meeting criteria
select count(*) plate_count (select plate anpr_in location='a35.1.ob.1' , date(time) between '2012-07-24' , '2012-09-02' group plate having count(*) > 10) x
you don't need distinct
because group by
reduces down distinct plate numbers.
Comments
Post a Comment