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 2012 Forums
 Transact-SQL (2012)
 Determine second highest date added

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2014-12-18 : 13:10:17
I am joining on a address table that has 6 addresses in a field labeled line 1
Along with another column date-added

I would like to get one primary and one secondary address from my join
To get primary I can easily say select Max date ,line1 from my address table

If there is only one address on line1 I can make line1 both primary and secondary
The problem now is if I have multiple addresses in line1 I would like to chose the next highest date that is not like my primary . How would I accomplish this

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-18 : 13:20:40
Please post some sample input and desired output.
Go to Top of Page
   

- Advertisement -