我正在使用以下代码来尝试UNION两组数据,虽然它运行时没有错误,但它运行超过10分钟并且没有返回结果,所以我想知道是否有某种东西我做错了吗?在查询和子查询中使用SQL中的UNION
select BIH.SourceCode, BIH.MarketValueAmt as CorrectedAmt
from [dbo].[IRA_HIST] as BIH
JOIN
(select accountno, accountclass
from accounttable
where accountclass in ('A','B','C','D')) AS AccountNos
ON BIH.ACCOUNTNO = ACCOUNTNOS.ACCOUNTNO
where BIH.securityno > '0'
UNION
SELECT SourceCode, (Amount*(-1)) as CorrectedAmt
from accttable a, activitytable b
where a.accountclass in ('A','B','C','D')
and b.recordtype in ('r','c')
任何指导都非常有帮助。
查看执行计划。 –
不幸的是,我没有在我的公司查看他们的权限/访问权限。 – SMBRADBE
然后得到它。如果您没有权限执行查询,则无需调试查询。 –