我正在尝试使用两个日期字段(开始日期和结束日期)从表中选择数据。where 子句中的两个日期字段都没有返回结果,并且 startdate 字段取出结果返回,这是怎么回事?任何人都可以帮助解决这个难题
我的代码是:
SELECT WPP.USERID,
WPI.EMAIL,
WPI.FIRSTNAME,
WPI.LASTNAME,
WPI.INSTITUTION
FROM WEBPROGRAMPARTICIPANTS WPP
JOIN WEBPERSONALINFO WPI ON WPP.USERID = WPI.USERID
JOIN WEBPROGRAMS WP ON WPP.PROGRAMCODE = WP.PROGRAMCODE
WHERE CONFIRMED = 1
AND WP.PROGRAMTYPE IN ('1')
AND WP.PROGRAMSTARTDATE >= '2009-01-02'
AND WP.PROGRAMENDDATE < '2009-09-15'
GROUP BY WPP.USERID,
WPI.EMAIL,
WPI.FIRSTNAME,
WPI.LASTNAME,
WPI.INSTITUTION
HAVING COUNT(WPP.PROGRAMCODE) > 1
ORDER BY WPP.USERID,
WPI.EMAIL
编辑:
这是要查看的结果集
USERID PROGRAMSTARTDATE PROGRAMENDDATE
------ ----------------------- -----------------------
26167 2009-03-09 00:00:00.000 2009-06-12 00:00:00.000
26362 2009-03-09 00:00:00.000 2009-06-12 00:00:00.000
26411 2009-03-09 00:00:00.000 2009-06-12 00:00:00.000
26491 2009-03-09 00:00:00.000 2009-06-12 00:00:00.000