March 20, 2013 at 12:25 am
Hi,
I am trying to join the table to itself many times on a condition. Is there a way to automate number of joins based on count of something from another table?
Any help appreciable!
Thanks,
Akber.
March 20, 2013 at 3:37 am
are you doing something that a Recursive CTE could resolve?
http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/
March 20, 2013 at 3:53 am
akberali67 (3/20/2013)
Hi,I am trying to join the table to itself many times on a condition. Is there a way to automate number of joins based on count of something from another table?
Any help appreciable!
Thanks,
Akber.
Could you please post a bit more details and code you have so far.
March 20, 2013 at 4:31 am
CTE wouldnt work because I am joining the table to itself meaning the field names would be the same and SQL doesnot accept that.
davidandrews13 (3/20/2013)
http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/%5B/quote%5D
March 20, 2013 at 5:43 am
akberali67 (3/20/2013)
davidandrews13 (3/20/2013)
sql handles that just fine as long as you rememeber to preface every field with it's table name.
SELECT
T1.*
T2.*
FROM MyTable T1
LEFT OUTER JOIN MyTable T2 On T1.ID = T2.ID +1
Lowell
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy