我想从满足一些条件的两条记录中提取其中一条的字段值,怎么写SQL语句呀?
比如:
select top 2 xingming from table where xingbie='男' and nianling>'25' order by riqi desc
上面的语句中,我想得到第二条记录的xingming,怎么写呢?
...全文
1148打赏收藏
急!从SQL语句提取字段值,请大虾帮忙!
我想从满足一些条件的两条记录中提取其中一条的字段值,怎么写SQL语句呀? 比如: select top 2 xingming from table where xingbie='男' and nianling>'25' order by riqi desc 上面的语句中,我想得到第二条记录的xingming,怎么写呢?
--或者:
declare @xingming varcahr(8000)
select top 2 @xingming =xingming from table where xingbie='男' and nianling>'25' order by riqi desc
select @xingming