--- 11月
---首次投资笔数和投资金额
SELECT COUNT(1) AS stNum,sum(amount) AS stAmount FROM ( select CONVERT(CHAR(10),createtime,120) AS riqi,a.amount,a.userID from
(
select ROW_NUMBER() over(partition by userID order by createtime ) as rowNum,*
from v_user_bid_record_list
) a
where a.rowNum <= 1 AND a.createtime>='2016-11-1' AND a.createtime<='2016-12-1' )
) AS ntt
使用
select ROW_NUMBER() over(partition by userID order by createtime ) as rowNum
取第一条