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.
| Author |
Topic |
|
edmyster
Starting Member
2 Posts |
Posted - 2010-01-14 : 16:07:14
|
| Hi,I am transferring Access queries to SQL and am just having some problems with keywords in Access being translated to SQL. The issue is with the First keywaord in Access.I have a table in SQL Server with a composite PK. They table is called UserFirm and the PK is made up of the UserID and FirmID. I need to select the distinct UserID and the first FirmID that the use belongs to eg...UserID FirmIDUxxx001 Fxxx001Uxxx002 Fxxx001Uxxx002 Fxxx002 Uxxx003 Fxxx002Uxxx004 Fxxx003so the result set i want returned is UserID FirmIDUxxx001 Fxxx001Uxxx002 Fxxx001Uxxx003 Fxxx002Uxxx004 Fxxx003Access uses the following SQL to do this:SELECT UserID, First(firm_id) AS Firm_idFROM UserFirmJust wondering if anybody knows the SQL equivalentcheers....Forgot to add using SQL 2005 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-01-14 : 16:13:19
|
MIN??select UserID, min(FirmID) from <urtable> group by UserID |
 |
|
|
edmyster
Starting Member
2 Posts |
Posted - 2010-01-14 : 16:24:46
|
| Cheers, seems to work a treat!! |
 |
|
|
|
|
|