1
select top 1 * from tablename where userid="&12345&" order by [time] desc"
或
select top 1 * from tablename where userid='"&12345&"' order by [time] desc"
哪个能用用哪个,因为不确定你userid的字段属性
2
select sum(num) from tablename where userid="&12345&" and month([time])=1"
1.select * from 表名 where userID=12345 and time in(select max(time) form 表名 )
2.select sum(num) as total from 表名 where month(time)=1 and userID=12345
select userid,num from 表名 where userid=12345 and time in(select max(time) from 表名 where userid=12345 )
select sum(num) as total from 表明 where month(time)=1 and userid=12345
用month()函数取自动获取时间里的月份