-1

大家好,我希望就如何最好地从我的表中选择数据提供一些帮助/见解/想法(我可以进行内部连接,但这与我的 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 ....
4

1 回答 1

1

通常,JOINs 往往比嵌套SELECT的 s 更快,因此请查看是否可以重新转换查询以使用它们。

另一种方法是查看查询的执行计划,查看哪个部分花费的时间最长,并尝试加快该部分的速度。这样做会极大地拓宽您对 SQL 的理解,因此即使只将执行时间缩短到 3h 55m,您也会从中获益良多。

于 2013-06-06T11:15:03.610 回答