sql server 2012 - large number of inner joins within the same table -
I have a scenario where all items are in a table called "table" I am doing it for two items: I / O asattartDate = JStartDate and IndDate = J.EndDate on INNER JOHN as the Table AS from SELECT IA + JA AS A, IB + JB AS B, IC + JC AS C, where IIemem = 602028 and J.ItemId = 602029
And I'm doing this for three items in the table:
Select IA + JA + KA A, IB + JB + KB ASB, IC + JC + K.C. As in the form of table from C. I am included in the form of J. in the form of IStartDate = J.StartDate and I.EndDate = J. Anddut Inner As Inner Joyine Table. StartDate = K.StartDate and IEDDT = K.andDit where IITMID = 602028 and JIITIID = 602029 and KITMID = 602030 So now you have an idea that I try to do I am doing; Straightforward Here the problem is that the number of items connecting is supplied at run time, and this number can be up to 200. My question is: What is the most effective way to do this? Currently it is becoming ugly on more than 5 pairs.
Not sure why you want aka and pivot as I do not think you want it the wanted.
To try the example ..
Declare the @table table (include ID int, an int, b int, c int, startdate date, expiration date) 123, 1, 1, 1, '2014-10-10', 'Tables (ID, A, B, C, Start, End) Select Union All Select 456, 2, 2, 2, '2014-10-10', '2014-10-10' Union All Select 789,3, 3, 3, '2014-10-10', '2014-10-10' Union All Select 111, 4, 4, 4, '2014-10-11', '2014-10-11' Association selection of all 222,4, 4, 4, '2014-10-11', '2014-10-11' selection In the form of ID (123456, 789, 111, 222) in the form by the initial date (endrat) A, the amount (B) C As A, B (B) as B, the amount (C) as C, initial,
Comments
Post a Comment