I worked with sql server 2008 and I used this command:
SELECT Min(id),
[idfromindex]
FROM ordersview
WHERE [idfromindex] IN(SELECT DISTINCT [idfromindex]
FROM ordersview
WHERE isobserve = 'True'
AND ispay = 'True'
AND orderdate >= '1390/09/01'
AND orderdate <= '1391/09/27')
GROUP BY [idfromindex]
But if there is a record with exactly orderdate='1390/09/01' or orderdate='1391/09/27' value it will not show them ,it only shows the result greater and lower than them but I want to show the equal one too if it exists.
orderDate type is Date
Wouldn’t changing the condition to being
>= '1390/09/01'and< '1391/09/28'make more sense? That way you remove the time components if a date is registered as being1390/09/01 23:59'. Date conditions tend to assume the exact time is00:00`. Of course it depends on what your column datatype is (datetime vs. date).