sql 取首次投资的人

 --- 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  

取第一条

posted @ 2016-12-01 13:46  沐雪架构师  阅读(306)  评论(0编辑  收藏  举报