MS SQL Server 2008中不支持第一个和最后一个函数 [英] First and Last Function not supported in MS SQL Server 2008

查看:79
本文介绍了MS SQL Server 2008中不支持第一个和最后一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我尝试使用第一个上一个功能时出现以下错误。



Msg 195,Level 15,State 10,Line 2

''FIRST''不是公认的内置函数名。



我在博客中读到 min max 功能可以用作替代品。还有其他选择吗?



先谢谢

Hi,

I get the following error when I try to use First and Last Function.

Msg 195, Level 15, State 10, Line 2
''FIRST'' is not a recognized built-in function name.

I read in a blog that min and max functions can be used as replacement. Is there any other alternative?

Thanks in Advance

推荐答案

看看W3Schools: http://www.w3schools.com/sql/sql_func_first.asp [ ^ ] - 如果函数不存在,它提供workround
Have a look at W3Schools: http://www.w3schools.com/sql/sql_func_first.asp[^] - it provides a workround if the function does not exist


或者你可以使用前1个与订购条款相结合



要获得最后一次,请使用

Alternatively you can use top 1 in conjuction with order by clause
i.e.
TO get last, use
Select top 1 column1 from yourtable Order by id Desc





要先获得,请使用



To get first, use

Select top 1 column1 from yourtable Order by id





希望帮助,如果是的话,将其标记为答案/ upvote。



谢谢

Milind



Hope that helps, if it does, mark it as answer/upvote.

Thanks
Milind


这篇关于MS SQL Server 2008中不支持第一个和最后一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆