Please start any new threads on our new
site at http://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Our new SQL Server Forums are live!
Come on over! We've restricted the ability to create new threads on these forums.
Flowing Fount of Yak Knowledge
Very Important crosS Applying yaK Herder
SELECT A, B, C,
CASE WHEN Rn=1 THEN 'CM' ELSE 'N' END AS D,
MAX( CASE WHEN Rn = 1 THEN B END) OVER(PARTITION BY A) E
FROM (SELECT A, B, C, DENSE_RANK() OVER(PARTITION BY A ORDER BY ABS(B-C)) RN
FROM @t) temp
quote:Originally posted by keka3309Thanks Chandu