大家好,我希望得到一些关于如何从我的表中最佳选择数据的帮助/见解/想法(我可以做内部联接,但这就像我的知识与SQL一样“复杂”)。好吧,我正在使用此查询,但需要4个小时
SELECT FROM
(
SELECT FROM
(
SELECT FROM )AS
)
AS ....
(SELECT ...FROM ... )AS...,
(SELECT .....FROM ... )
AS ...
(SELECT ........FROM ....) AS ....
(SELECT....FROM .... )AS ...
(SELECT ...FROM .... )AS ...,
(SELECT .....FROM ..... )AS [.....
( SELECT .....FROM ..... )AS [.....
(SELECT .....FROM ..... ) AS [.....
(SELECT .....FROM ..... ) AS [.....
(SELECT .....FROM ..... ) AS [.....
WHERE
(
And (
And ....
答案 0 :(得分:1)
通常,JOIN
s往往比嵌套SELECT
更快,因此请查看是否可以重新构建查询以使用它们。
另一种方法是查看查询的执行计划,查看哪个部分需要最长时间并尝试加速该部分。在这样做的过程中,你将大大扩展你对SQL的理解,所以即使它只需要将执行时间缩短到3小时55分,你也可以从中获得很多。