我有这个问题:
Select *
From Player_Chkin_Cs
吐出结果:
Player_ID CS_ID CS_LISTING_ID CS_COMP_NAME PT_ADD CREATE_DTIME UUID
179364 300 60132 Wilshire 3 22-DEC-10 (null)
179364 320 68968 Wilshire 30 28-JAN-10 (null)
132489 200 55168 Wilshire 13 03-Jan-10 (null)
132489 900 65478 Wilshire 23 15-Feb-10 (null)
我想创建一个查询,该查询只返回create_dtimes同时属于01-Dec-10到31-Dec-10以及01-Jan-10到31-Jan-10范围内的玩家的player_ids。 (也就是说,只有Player_ID 179364会出现在这个例子的结果中)
如果您有任何建议,请与我们联系!
答案 0 :(得分:2)
一个选项是
SELECT player_id,
COUNT(DISTINCT trunc(create_dtime, 'MM')) num_months
FROM player_chkin_cs
WHERE trunc(create_dtime,'MM') IN (date '2010-12-01', date '2010-01-01')
GROUP BY player_id
HAVING COUNT(DISTINCT trunc(create_dtime, 'MM')) = 2