Hi,
I always thought there was a way to have the Last record of the group of
records that accorded to your query. But when I tried "LAST" this didn't
work really (althoug the Query analyzer recognized it as a valid
statement?).
I'm able to replace it with a "TOP 1" and an "ORDER BY DESC", but I would
really be nice if there was something like a LAST and FIRST-function.
I have now:
SELECT TOP 1 c21.*
FROM c21
WHERE (c21.Text LIKE '21%')
ORDER BY c21.ID DESC
But it would be nicer if this could be without the ORDER BY and some
LAST-function:
LAST(c21.ID), c21.*
FROM c21
WHERE (c21.Text LIKE '21%')
Anybody knows anything about this subject? hehe :-)
Thanks a lot in advance,
PieterThat would imply that a table is ordered, which it isn't.
(Think about it, for each way to represent information, you need 4 set of
operators, read, add, remove and change. In SQL, we already have SELECT,
INSERT, DELETE and UPDATE. I don't think we want 4 more operators just to
add the concept of ordered tables.)
However, Yukon will probably have some language constructs which make paging
and stuff a bit easier to manage.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"DraguVaso" <pietercoucke@.hotmail.com> wrote in message
news:eNryScgAEHA.3004@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I always thought there was a way to have the Last record of the group of
> records that accorded to your query. But when I tried "LAST" this didn't
> work really (althoug the Query analyzer recognized it as a valid
> statement?).
> I'm able to replace it with a "TOP 1" and an "ORDER BY DESC", but I would
> really be nice if there was something like a LAST and FIRST-function.
> I have now:
> SELECT TOP 1 c21.*
> FROM c21
> WHERE (c21.Text LIKE '21%')
> ORDER BY c21.ID DESC
> But it would be nicer if this could be without the ORDER BY and some
> LAST-function:
> LAST(c21.ID), c21.*
> FROM c21
> WHERE (c21.Text LIKE '21%')
>
> Anybody knows anything about this subject? hehe :-)
> Thanks a lot in advance,
> Pieter
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment