SQL self join multiple times
问题 I have a single database table that stores week entries. Id Value WeekId 1 1.0000 1 2 2.0000 1 There can be up to three entries with the same week. So I figured using a self join would solve this SELECT w1.Value, w2.Value, w3.Value FROM [List].[dbo].[testWeekEntries] as w1 LEFT OUTER JOIN [List].[dbo].[testWeekEntries] as w2 ON w1.WeekId = w2.weekId LEFT OUTER JOIN [List].[dbo].[testWeekEntries] as w3 ON w2.WeekId = w3.WeekId WHERE w1.Id < w2.Id AND w2.Id < w3.Id The problem: It worls fine