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 |
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-02-16 : 11:39:52
|
| I am trying to return 1 record for each PN but in some case will return 2 because there are two entries, just a different BUYERSELECT LEADTIMEID, SUPPNO, PN, BUYER, LEADTIME, UPDATEDLEADTIME, UPDATEDLEADTIMEDATE, IsPending, DateAddedFROM CS_LeadTimeWHERE (DateAdded = (SELECT TOP 1 DateAdded FROM CS_LeadTime))ORDER BY PNI am trying to return the MAX(LEADTIMEID) of the two Right now it returns something like this for a specified PNLEADTIMEID SUPPNO PN BUYER5609 1234 ABC123 JR5610 1234 ABC123 LCI just wantLEADTIMEID SUPPNO PN BUYER5610 1234 ABC123 LC |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-02-16 : 12:40:08
|
| How do you decide whether you want BUYER = LC to appear in preference to BUYER = JR?Could you use MIN(BUYER) to solve that part? Or do you need the buyer with the MAX(LEADTIMEID)? What if there are two BUYERs with the same MAX(LEADTIMEID)?Kristen |
 |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2007-02-16 : 13:00:14
|
| Thanks for your reply Kristen, I need the buyer with the MAX(LEADTIMEID)The LEADTIMEID is unique. |
 |
|
|
|
|
|