mysql - Not selecting the id which unsatisfy condition using sql -
i have table repid , date.
table: 1 repid logtime 108981 2013-04-09 00:00:00.000 108981 2013-04-09 00:00:00.000 108981 2013-04-11 00:00:00.000 108981 2013-04-11 00:00:00.000 108981 2013-04-11 00:00:00.000 108982 2013-04-09 00:00:00.000 108982 2013-04-10 00:00:00.000 108982 2013-04-11 00:00:00.000 108982 2013-04-11 00:00:00.000 108982 2013-04-11 00:00:00.000
i want regret repid table 1 if atleast 1 date in date range specified in condition didnot match.
i have written query like
select tl.repid table1 tl convert(date, logtime) > convert(date,'2013-04-08 00:00:00.000') , convert(date, logtime) < convert(date,'2013-04-12 00:00:00.000')
here output
repid 108981 108982
but want
repid 108982
as repid - 108981 not have date '2013-04-10 00:00:00.000' specified in condition.
----or----- how take repid , date not satisfied.....
please overcome problem.........
try this...
select repid (select repid ,(select count(distinct cast(logtime date)) t cast( a.logtime date) > cast('2013-04-08 00:00:00.000' date) , cast( a.logtime date) < cast('2013-04-12 00:00:00.000' date) , a.repid=b.repid) counts t b) c counts=datediff('2013-04-12 00:00:00.000','2013-04-08 00:00:00.000')-1 group repid
Comments
Post a Comment