You can't do such logic in a single SQL Statement. If it was recursion then you could do WITH statement in SQL Server.
http://databaseandstorage.blogspot.com http://gotodba.weebly.com
Forum Rules