Thanks in advance for any insight on this one. I have a composite key that is formed by a customer id and an address sequence number. Each time a address sequence is added to a customer a new Address id is added. If I perform a Max() on the sequence number and group by the customer id I get the correct rows back but I cannot pull the address id as it is not an aggregate or in the group by.
CustId SeqNum AddressId
1000 1 20001
1000 2 23409
1000 3 24706
1000 4 25103
Basically I need to pull the AddressId of 25103 as it is the highest sequence number for customer 1000.
Returns my CustId of 1000 and SeqNum of 4 but I need the AddressId. Any thoughts?
If you choose to battle wits with the witless be prepared to lose.
![[cheers] [cheers] [cheers]](/data/assets/smilies/cheers.gif)
CustId SeqNum AddressId
1000 1 20001
1000 2 23409
1000 3 24706
1000 4 25103
Basically I need to pull the AddressId of 25103 as it is the highest sequence number for customer 1000.
Code:
Select CustId, Max(SeqNum) from tblCust Group By CustId
If you choose to battle wits with the witless be prepared to lose.
![[cheers] [cheers] [cheers]](/data/assets/smilies/cheers.gif)