2012年3月7日星期三

First() and last() function -> course says yes, Book on line says no

Richard,

> Could they make that big a mistake?
Apparently so :-)
Chief Tenaya
"Richard Fagen" <no_spam@.my_isp.com> wrote in message
news:eGRLEejHEHA.3464@.TK2MSFTNGP10.phx.gbl...
> Hi Everyone,
> I'm taking an online course to learn more about SQL. I found this great
> site...
> http://www.w3schools.com/sql/default.asp
> In one of the lessons, it mentions SQL server's functions. However,
> when I tried it, it doesn't work. I checked the Books online and it
> appears there is no such function. Could they make that big a mistake?
> I know there are other ways of doing the same thing but I found the site
> very accurate and this surprises me.
> Here is the page in question. The problems: it claims there is a First
> (and Last) function...
> http://www.w3schools.com/sql/func_first.asp
> -- here is their example
> "The FIRST function returns the value of the first record in the
> specified field.
> Tip: Use the ORDER BY clause to order the records!
> Syntax
> SELECT FIRST(column) AS [expression]
> FROM table
> Example
> SELECT FIRST(Age) AS lowest_age
> FROM Persons
> ORDER BY Age"
You need the TOP modifier. eg.
SELECT TOP 1 Age AS lowest_age
FROM Persons
ORDER BY Age
HTH,
Greg Low (MVP)
MSDE Manager SQL Tools
www.whitebearconsulting.com
"Richard Fagen" <no_spam@.my_isp.com> wrote in message
news:eGRLEejHEHA.3464@.TK2MSFTNGP10.phx.gbl...
> Hi Everyone,
> I'm taking an online course to learn more about SQL. I found this great
> site...
> http://www.w3schools.com/sql/default.asp
> In one of the lessons, it mentions SQL server's functions. However,
> when I tried it, it doesn't work. I checked the Books online and it
> appears there is no such function. Could they make that big a mistake?
> I know there are other ways of doing the same thing but I found the site
> very accurate and this surprises me.
> Here is the page in question. The problems: it claims there is a First
> (and Last) function...
> http://www.w3schools.com/sql/func_first.asp
> -- here is their example
> "The FIRST function returns the value of the first record in the
> specified field.
> Tip: Use the ORDER BY clause to order the records!
> Syntax
> SELECT FIRST(column) AS [expression]
> FROM table
> Example
> SELECT FIRST(Age) AS lowest_age
> FROM Persons
> ORDER BY Age"

没有评论:

发表评论