December 25, 2006 at 5:35 pm
Hi,
The great FIRST and LAST functions in SQL 2005 are a great assett, but they weren't implemented in 2K. Is there a way to produce similar functionality in 2K by using some coding method?
Any help appreciated.
Thanks!
December 25, 2006 at 7:44 pm
I'm sure we can figure something out. Can you tell us exactly what you are working with (DDL and sample data) and what you need (sample output) and we'll see if we can fix you up.
December 25, 2006 at 9:32 pm
James,
I did a search in BOL 2005 and on google... couldn't find reference to a FIRST or LAST function. Probably my problem since I don't use 2005, yet, but do you have a reference that describes what these two functions do so we can figure something out in 2k? Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 25, 2006 at 11:23 pm
You'd want to do something like this:
select top 1 t.*
from mytable t join (select min(some_field) first from mytable) f on t.some_field = f.first
or
select top 1 t.*
from mytable t join (select max(some_field) last from mytable) f on t.some_field = f.last
December 26, 2006 at 3:58 am
last=
select top 1 * from mytable order by myfield desc
first=
select top 1 * from mytable order by myfield asc
??
MVDBA
December 26, 2006 at 4:30 am
That works brilliantly. I'm starting a new job on 2nd January and have been trying to tone up my SQL skills before then.
I'm surprised that I had so many responses!
Haven't you all got better things to do on Christmas Day??!
December 26, 2006 at 4:54 am
i wish - i'm in the office
MVDBA
December 26, 2006 at 7:18 am
I would like to but I'm a little sort this year... and I can cam up with a few Ks this week alone so I'm working this year.
Viewing 8 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply