Hello, I have the following query, that runs also on several online tables:
SELECT [T1].E1, [T1].E2, [T1].E7, [T1].E8, [T1].E9, [T1].E10, [T2].E9, [T2].E10, [T2].E11, [T2].E12, [T2].E13, [T2].E14, [T2].E15, [T2].E16, [T2].E17, [T2].E18, [T2].E19, [T2].E20, [T2].E21, [T2].E22, [T2].E23, [T2].E24, [T3].E25, [T3].E26, [T3].E27, [T3].E28, [T3].E29, [T3].E30, [T3].E31, [T3].E32, [T3].E33, [T3].E34, [T3].E35, [T3].E36, [T3].E18, [T4].E37, [T4].E38, [T4].E39, [T4].E40, [T4].E41, [T4].E42, [T4].E43, [T4].E44, [T4].E45, [T6].E46, [T6].E47, [T6].E48, [T8].[E49], [T8].[E50], [T8].[E51], [T8].[E52], [T8].[E53], [T8].[E54], [T8].[E55], [T8].[E56], [T8].[E57], [T8].[E58], [T8].[E59], [T8].[E60], [T7].[E61], [T7].[E62], [T7].[E63], [T7].[E64], [T7].[E65], [T7].[E66], [T8].[E75], [T8].[E69], T5.E71, [T8].[E68], [T8].[E67], [T6].E6, [T8].[E72], [T8].[E73], [T8].[E70], [T8].[E74], [T8].[E80], [T8].[E82], [T8].[E81], [T8].[E83], [T8].[E76], [T8].[E77], [T8].[E79], [T8].[E78], [T8].[E5], [T8].[E4], [SumOfXX]/2 AS XX INTO [T11]
FROM ((((((([T1] LEFT JOIN [T2] ON [T1].E2 = [T2].E2) LEFT JOIN [T3] ON [T1].E2 = [T3].E2) LEFT JOIN [T4] ON [T1].E2 = [T4].E2) LEFT JOIN [T6] ON [T1].E2 = [T6].E2) LEFT JOIN [T8] ON [T1].E2 = [T8].YY) LEFT JOIN [T7] ON [T1].E2 = [T7].E2) LEFT JOIN T5 ON [T1].E2 = T5.E2) LEFT JOIN [T10] ON [T1].E2 = [T10].E3
ORDER BY [T1].E1, [T1].E2;
As the title says, it doesn't sort. Or better: if you switch the visualization of that query from Design View to Table View, your chances of having it creating a sorted table (T11) gets bigger.
I literally mean: run the query as it is, and T11 will never be sorted. Open the query in table view, close table view, run it: ok, now T11 may be sorted (let's say 60% chance). If T11 is still not sorted, repeat until it's sorted (it doesn't get sorted better and better, though, it is either sorted or not).
The query has to be launched automatically at 6:00 AM, so having a person switching manually the view is not an option.
What is the problem here?
Thank you very much
SELECT [T1].E1, [T1].E2, [T1].E7, [T1].E8, [T1].E9, [T1].E10, [T2].E9, [T2].E10, [T2].E11, [T2].E12, [T2].E13, [T2].E14, [T2].E15, [T2].E16, [T2].E17, [T2].E18, [T2].E19, [T2].E20, [T2].E21, [T2].E22, [T2].E23, [T2].E24, [T3].E25, [T3].E26, [T3].E27, [T3].E28, [T3].E29, [T3].E30, [T3].E31, [T3].E32, [T3].E33, [T3].E34, [T3].E35, [T3].E36, [T3].E18, [T4].E37, [T4].E38, [T4].E39, [T4].E40, [T4].E41, [T4].E42, [T4].E43, [T4].E44, [T4].E45, [T6].E46, [T6].E47, [T6].E48, [T8].[E49], [T8].[E50], [T8].[E51], [T8].[E52], [T8].[E53], [T8].[E54], [T8].[E55], [T8].[E56], [T8].[E57], [T8].[E58], [T8].[E59], [T8].[E60], [T7].[E61], [T7].[E62], [T7].[E63], [T7].[E64], [T7].[E65], [T7].[E66], [T8].[E75], [T8].[E69], T5.E71, [T8].[E68], [T8].[E67], [T6].E6, [T8].[E72], [T8].[E73], [T8].[E70], [T8].[E74], [T8].[E80], [T8].[E82], [T8].[E81], [T8].[E83], [T8].[E76], [T8].[E77], [T8].[E79], [T8].[E78], [T8].[E5], [T8].[E4], [SumOfXX]/2 AS XX INTO [T11]
FROM ((((((([T1] LEFT JOIN [T2] ON [T1].E2 = [T2].E2) LEFT JOIN [T3] ON [T1].E2 = [T3].E2) LEFT JOIN [T4] ON [T1].E2 = [T4].E2) LEFT JOIN [T6] ON [T1].E2 = [T6].E2) LEFT JOIN [T8] ON [T1].E2 = [T8].YY) LEFT JOIN [T7] ON [T1].E2 = [T7].E2) LEFT JOIN T5 ON [T1].E2 = T5.E2) LEFT JOIN [T10] ON [T1].E2 = [T10].E3
ORDER BY [T1].E1, [T1].E2;
As the title says, it doesn't sort. Or better: if you switch the visualization of that query from Design View to Table View, your chances of having it creating a sorted table (T11) gets bigger.
I literally mean: run the query as it is, and T11 will never be sorted. Open the query in table view, close table view, run it: ok, now T11 may be sorted (let's say 60% chance). If T11 is still not sorted, repeat until it's sorted (it doesn't get sorted better and better, though, it is either sorted or not).
The query has to be launched automatically at 6:00 AM, so having a person switching manually the view is not an option.
What is the problem here?
Thank you very much