Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 MS Access Query Conversion

Author  Topic 

JimAmigo
Posting Yak Master

119 Posts

Posted - 2004-07-13 : 12:02:05
I am converting some queries in an old MS Access application to SQL Sever.

Query analyzer doesn't like the "First" Record parameter in this query. What is the proper way to run the same query for the First record.

SELECT tbl_RelativeFrocked.SocialSecurityNumber, First(tbl_RelativeFrocked.ActualRank) AS [Frocked Rank], Max(tbl_RelativeFrocked.DateOfRank) AS [MaxOfDate Of Rank]
FROM tbl_RelativeFrocked
GROUP BY tbl_RelativeFrocked.SocialSecurityNumber;

I am sure this is probably a simple question but lack the knowledge to answer it myself.

Thanks for your help!



Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-07-13 : 12:23:37
There isn't a first() in SQL.

Sometimes you can get by with min() or max(). If the column is always the same you could group by that column as well

Corey
Go to Top of Page

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-07-13 : 12:25:05
It depends on what you are trying to get.

Some DDL (CREATE TABLE..), DML (INSERT TABLE...) and expected results will help us help you.
Go to Top of Page

JimAmigo
Posting Yak Master

119 Posts

Posted - 2004-07-13 : 12:53:27
I have been comparing the results and it looks like I can get away with using MAX.

Thank you for your help.
Go to Top of Page
   

- Advertisement -