May 29, 2003 at 7:28 am
I'm upgrading from Access to SQL Server and have to translate to T-SQL a number of queries which use the 'First' and 'Last' functions that Jet uses ... only I can't seem to find equivalents in T-SQL. Is there an easy answer to this? please, please someone tell me there's an easy answer ..
May 29, 2003 at 7:33 am
Look in BooksOnline for Aggregate functions:
MIN(), MAX(), AVG(), SUM(), COUNT()...
May 29, 2003 at 8:42 am
But he's asking about First and Last, which don't have corresponding functions in T-SQL. I've wished for these at times myself.
Jay Madren
Jay Madren
May 29, 2003 at 8:45 am
What's the difference between MIN and First and MAX and Last. YOu can also use TOP clause and the order by clause to produce the results needed.
Edited by - jpipes on 05/29/2003 08:48:18 AM
May 29, 2003 at 9:10 am
In Access, the First and Last functions allow you to retrieve the first or last value (field) within a Group, where the order is not by that field (i.e., ordered by some other field).
Jay Madren
Jay Madren
May 29, 2003 at 9:14 am
quote:
In Access, the First and Last functions allow you to retrieve the first or last value (field) within a Group...
That is percisely what MIN and MAX do.
Example:
SELECT OrderGroup, MIN(ReceivedOn) AS EarliestReceived, MAX(ReceivedOn) AS LatestReceived
FROM OrderTable
GROUP BY OrderGroup
May 29, 2003 at 9:16 am
There are Min & Max functions for Jet/Access, I assume they're equivalent to their namesakes in T-SQL. This is doing my head in - can anyone out there think of a workaround?
May 29, 2003 at 9:18 am
quote:
..can anyone out there think of a workaround?...
What are you trying to work around? If you post the Jet code, we can translate it to T-SQL...
May 29, 2003 at 9:39 am
quote:
What are you trying to work around? If you post the Jet code, we can translate it to T-SQL...
It's alright, I've tried using Min & Max and it all appears to work fine. Thanks fellas.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply