I'm in the process of trying to speed up my queries. A lot of them are quite complicated, and currently I mostly achieve this through creating multiple queries and linking them through joins.
Is this best practice, or should I be using SELECT
s within SELECT
s and trying to achieve the same thing within one query?
Will either option have an effect on speed, or is complicated just complicated?
EDIT: Example query below
SELECT HoldingCoNos.ID
FROM (
SELECT [SearchByName - No Filter].ID
FROM [SearchByName - No Filter]
INNER JOIN [SearchByName - Level 1 Subsidiaries]
ON [SearchByName - No Filter].ID = [SearchByName - Level 1 Subsidiaries].[Holding Company]
) AS HoldingCoNos
GROUP BY HoldingCoNos.ID;
This is with it all in one query - the other option is to create the contents of the FROM section of the query as two seperate queries, save them and use an inner join.