Id | Status | Value | CreatedDateTime
-----+--------+--------+------------------------
1 | Open | Y | 2014-12-10 14:03:10.100
2 | Open | Y | 2014-12-10 13:03:10.100
3 | Open | N | 2014-12-10 13:01:12.100
4 | Open | Y | 2014-12-10 05:02:11.100
5 | Open | N | 2014-12-09 15:03:10.100
6 | Open | N | 2014-12-08 14:03:10.100
7 | Open | Y | 2014-12-08 14:03:10.100
I wants to write a SQL query to get the records from 2014-12-08 14:03:10.100
to 2014-12-10 14:03:10.100
and also the Status
should be Open
with Value = Y
.
I tried below sql query-
select *
from mytable
where CreatedDateTime between '2014-12-08 14:03:10.100' and '2014-12-10 14:03:10.100'
and Status in ('Open') and Value='Y'