通过 JDBC 的 SQL Server FIRST 函数
我正在构建一个具有 SQL Server 数据库连接的冷聚变应用程序。我需要组记录,并且只返回组中的第一个。我在 Coldfusion 中编写了以下查询。
SELECT FIRST(ID)
FROM table
GROUP BY NAME
返回以下错误:
[Macromedia][SQLServer JDBC 驱动程序][SQLServer]'first' 不是可识别的内置函数名称。
是否可以在 Coldfusion 查询中使用第一个函数?
是否有其他方法可以实现此目的?< /em>
*我无法直接访问数据库。只需访问冷聚变数据连接
I am building an application in cold fusion which has a SQL Server database connection. I need group records and only return the first in the group. I wrote the following query in coldfusion.
SELECT FIRST(ID)
FROM table
GROUP BY NAME
Which is returning the following error:
[Macromedia][SQLServer JDBC Driver][SQLServer]'first' is not a recognized built-in function name.
Is the a way use the first function in a coldfusion query?
Is there an alternative way to accomplishment this?
*I do not have direct access to the database. Just a access to the cold fusion data connection
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
FIRST
在 SQL Server 中无效(您一定想到的是 Access)。也许您的意思是:在 SQL Server“Denali”中,您将能够将
FIRST_VALUE
/LAST_VALUE
与窗口函数结合使用。FIRST
is not valid in SQL Server (you must be thinking of Access). Maybe you meant:In SQL Server "Denali" you will be able to use
FIRST_VALUE
/LAST_VALUE
in conjunction with windowing functions.FIrst和Last在Sql Server 2005或2008中不存在,但在Sql Server 2012中存在FirstValue、LastValue函数。我尝试为 Sql Server 2005 实现聚合 First 和 Last,但遇到了一个障碍:sql server 确实保证按照定义的顺序计算聚合。 (请参阅属性 SqlUserDefinedAggregateAttribute.IsInvariantToOrder 属性,该属性未实现。)
这可能是因为查询分析器尝试在多个线程上执行聚合计算并组合结果,这可以加快执行速度,但不能保证元素聚合的顺序。
FIrst and Last do not exist in Sql Server 2005 or 2008, but in Sql Server 2012 there is a FirstValue, LastValue function. I tried to implement the aggregate First and Last for Sql Server 2005 and came to the obstacle that sql server does guarantee the calculation of the aggregate in a defined order. (See attribute SqlUserDefinedAggregateAttribute.IsInvariantToOrder Property, which is not implemented.)
This might be because the query analyser tries to execute the calculation of the aggregate on multiple threads and combine the results, which speeds up the execution, but does not guarantee an order in which elements are aggregated.