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
FIRST
is not valid in SQL Server (you must be thinking of Access). Maybe you meant:
SELECT NAME, MIN(ID)
FROM dbo.table
GROUP BY NAME;
In SQL Server "Denali" you will be able to use FIRST_VALUE
/LAST_VALUE
in conjunction with windowing functions.