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
取第一条
作者:沐雪
文章均系作者原创或翻译,如有错误不妥之处,欢迎各位批评指正。本文版权归作者和博客园共有,如需转载恳请注明。
如果您觉得阅读这篇博客让你有所收获,请点击右下方【推荐】
为之网-热爱软件编程 http://www.weizhi.cc/