我有日志表,其中记录了用户 ID 和完成特定活动的日期。我想获得每个月都有活动的用户的名字。我正在使用以下查询
select distinct(employeeid) from transactions
where eventdate between '01-OCT-13' AND '23-OCT-13'
and eventdate between '01-SEP-13' AND '01-OCT-13'
and eventdate between '01-AUG-13' AND '01-SEP-13'
and eventdate between '01-JUL-13' AND '01-AUG-13';
但这是行不通的。有人可以建议任何改进吗?
编辑: 由于我的问题似乎有点混乱,这里有一个例子
EmployeeID | Timestamp
a | 01-Jul-13
b | 01-Jul-13
a | 01-Aug-13
c | 01-Aug-13
a | 01-Sep-13
d | 01-Sep-13
a | 01-Oct-13
a | 01-Oct-13
在上表中,我们可以看到员工“a”在从 7 月到 10 月的所有月份都有活动。所以我想找到所有这些员工的名单。