SQL结构
id, startdate, enddate
1, 2012-01-01, 2012-10-01
我需要sql statment来接收从startdate到enddate范围的重复行。
示例结果将是:
1, 2012-01-01
1, 2012-02-01
1, 2012-03-01
...
1, 2012-10-01
有没有人知道如何解决这个问题?
答案 0 :(得分:0)
它应该是这样的:
SELECT
id, startdate, enddate
FROM
myTable
WHERE
(startdate, enddate) IN
(
SELECT
startdate, enddate
FROM
myTable
GROUP BY
startdate, enddate
HAVING
COUNT(*) > 1
)