Home Forums SQL Server 2008 T-SQL (SS2K8) Find Row Number Based on Column Information RE: Find Row Number Based on Column Information
Alexander Suprun
SSCertifiable
Points: 6233
More actions
February 20, 2013 at 1:25 pm
#1589717
DECLARE @ID INT = 2
SELECT TOP 1 * FROM #tTestTB
WHERE VisOrder < @ID AND TreeType = 'S'
AND EXISTS(SELECT * FROM #tTestTB WHERE VisOrder = @ID AND TreeType <> 'S')
ORDER BY VisOrder DESC