Re: Help with an Update Statment
- From: "Plamen Ratchev" <Plamen@xxxxxxxxxxxxx>
- Date: Tue, 27 May 2008 12:09:51 -0400
Try this:
UPDATE tbl_Output
SET OfficerSID1 = (SELECT TOP 1 OfficerSID
FROM Co AS C
WHERE C.custID = tbl_Output.custID
ORDER BY OfficerRank, OfficerSID),
OfficerSID2 = (SELECT TOP 1 OfficerSID
FROM (SELECT TOP 2 OfficerRank, OfficerSID
FROM Co AS C
WHERE C.custID = tbl_Output.custID
ORDER BY OfficerRank, OfficerSID) AS T
ORDER BY OfficerRank DESC, OfficerSID DESC);
HTH,
Plamen Ratchev
http://www.SQLStudio.com
.
- Follow-Ups:
- Re: Help with an Update Statment
- From: thetaamommy
- Re: Help with an Update Statment
- References:
- Re: Help with an Update Statment
- From: Plamen Ratchev
- Re: Help with an Update Statment
- From: thetaamommy
- Re: Help with an Update Statment
- Prev by Date: Re: delete a named instance - how?
- Next by Date: Re: SQL Server Browser service?
- Previous by thread: Re: Help with an Update Statment
- Next by thread: Re: Help with an Update Statment
- Index(es):