怎么给这个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
展开全部
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询