1

我有这个查询:

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 将显示在此示例的结果中)

如果您有任何建议,请告诉我!

4

1 回答 1

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
于 2012-10-11T00:46:58.387 回答