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
 SQL Server Development (2000)
 Query Help

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 BUYER

SELECT LEADTIMEID, SUPPNO, PN, BUYER, LEADTIME, UPDATEDLEADTIME, UPDATEDLEADTIMEDATE, IsPending, DateAdded
FROM CS_LeadTime
WHERE (DateAdded =
(SELECT TOP 1 DateAdded
FROM CS_LeadTime))
ORDER BY PN

I am trying to return the MAX(LEADTIMEID) of the two
Right now it returns something like this for a specified PN
LEADTIMEID SUPPNO PN BUYER
5609 1234 ABC123 JR
5610 1234 ABC123 LC

I just want
LEADTIMEID SUPPNO PN BUYER
5610 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
Go to Top of Page

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.
Go to Top of Page
   

- Advertisement -