我使用 sql server 2008 并使用了以下命令:
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]
但是,如果有一个确切orderdate='1390/09/01'
或orderdate='1391/09/27'
值的记录,它不会显示它们,它只会显示大于和小于它们的结果,但如果它存在,我也想显示相等的结果。
orderDate 类型为 Date