怎么给这个SQL语句进行下优化,能让他运行速度更快。。在线等
SELECTa.POSID,a.StoreID,[FinalStatus],a.[BranchID],a.CreatedDate,c.DeletedDateFROM[PO...
SELECT a.POSID ,
a.StoreID ,
[FinalStatus] ,
a.[BranchID] ,
a.CreatedDate ,
c.DeletedDate
FROM [POSMacStatus] a
INNER JOIN ( SELECT POSID ,
StoreID ,
MAX(ts) ts ,
[BranchID]
FROM POSMacStatus
GROUP BY [BranchID],
POSID ,
StoreID
) b ON a.POSID = b.POSID
AND a.StoreID = b.StoreID
AND a.ts = b.ts
AND a.BranchID = b.BranchID
INNER JOIN dbo.PlazaStoreInfo c ON b.BranchID = c.BranchID
AND b.StoreID = c.StoreID
c.DeletedDate怎么报错了呢。。。 展开
a.StoreID ,
[FinalStatus] ,
a.[BranchID] ,
a.CreatedDate ,
c.DeletedDate
FROM [POSMacStatus] a
INNER JOIN ( SELECT POSID ,
StoreID ,
MAX(ts) ts ,
[BranchID]
FROM POSMacStatus
GROUP BY [BranchID],
POSID ,
StoreID
) b ON a.POSID = b.POSID
AND a.StoreID = b.StoreID
AND a.ts = b.ts
AND a.BranchID = b.BranchID
INNER JOIN dbo.PlazaStoreInfo c ON b.BranchID = c.BranchID
AND b.StoreID = c.StoreID
c.DeletedDate怎么报错了呢。。。 展开
2个回答
展开全部
抱歉,没仔细看,试试这个:
SELECT a.POSID ,
a.StoreID ,
[FinalStatus] ,
a.[BranchID] ,
a.CreatedDate ,
b.DeletedDate
FROM [POSMacStatus] a
INNER JOIN ( SELECT bb.POSID ,
bb.StoreID ,
MAX(bb.ts) ts ,
bb.[BranchID],
cc.DeletedDate
FROM POSMacStatus bb
INNER JOIN dbo.PlazaStoreInfo cc
ON bb.[BranchID] = cc.[BranchID]
AND bb.StoreID = cc.StoreID
GROUP BY bb.[BranchID],
bb.POSID ,
bb.StoreID,
cc.DeletedDate
) b
ON a.POSID = b.POSID
AND a.StoreID = b.StoreID
AND a.ts = b.ts
AND a.BranchID = b.BranchID
SELECT a.POSID ,
a.StoreID ,
[FinalStatus] ,
a.[BranchID] ,
a.CreatedDate ,
b.DeletedDate
FROM [POSMacStatus] a
INNER JOIN ( SELECT bb.POSID ,
bb.StoreID ,
MAX(bb.ts) ts ,
bb.[BranchID],
cc.DeletedDate
FROM POSMacStatus bb
INNER JOIN dbo.PlazaStoreInfo cc
ON bb.[BranchID] = cc.[BranchID]
AND bb.StoreID = cc.StoreID
GROUP BY bb.[BranchID],
bb.POSID ,
bb.StoreID,
cc.DeletedDate
) b
ON a.POSID = b.POSID
AND a.StoreID = b.StoreID
AND a.ts = b.ts
AND a.BranchID = b.BranchID
七鑫易维信息技术
2024-09-02 广告
2024-09-02 广告
Play Video 七鑫易维是致力于机器视觉和人工智能领域的高新科技企业,迄今已专注眼球追踪技术的研发、创新与应用超过14年,拥有完全自主知识产权,全球专利总量655余项。 作为眼球追踪技术领域的全球知名品牌,七鑫易维的产品体系覆盖眼动分...
点击进入详情页
本回答由七鑫易维信息技术提供
展开全部
SELECT a.POSID ,
a.StoreID ,
[FinalStatus] ,
a.[BranchID] ,
a.CreatedDate ,
c.DeletedDate
FROM [POSMacStatus] a
INNER JOIN ( SELECT bb.POSID ,
bb.StoreID ,
MAX(bb.ts) ts ,
bb.[BranchID]
FROM POSMacStatus bb
INNER JOIN dbo.PlazaStoreInfo cc
ON bb.[BranchID] = cc.[BranchID]
AND bb.StoreID = cc.StoreID
GROUP BY bb.[BranchID],
bb.POSID ,
bb.StoreID
) b
ON a.POSID = b.POSID
AND a.StoreID = b.StoreID
AND a.ts = b.ts
AND a.BranchID = b.BranchID
a.StoreID ,
[FinalStatus] ,
a.[BranchID] ,
a.CreatedDate ,
c.DeletedDate
FROM [POSMacStatus] a
INNER JOIN ( SELECT bb.POSID ,
bb.StoreID ,
MAX(bb.ts) ts ,
bb.[BranchID]
FROM POSMacStatus bb
INNER JOIN dbo.PlazaStoreInfo cc
ON bb.[BranchID] = cc.[BranchID]
AND bb.StoreID = cc.StoreID
GROUP BY bb.[BranchID],
bb.POSID ,
bb.StoreID
) b
ON a.POSID = b.POSID
AND a.StoreID = b.StoreID
AND a.ts = b.ts
AND a.BranchID = b.BranchID
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询