您有一个列级联,可防止任何索引的使用
尝试不存在将分别支持2列
SELECt distinct o.casino_id, g.game_idFROM game g INNER JOIN Bet b ON g.game_id = b.game_id INNER JOIN CasinoUser u ON b.user_id = u.user_id INNER JOIN onewalletcasino o ON u.casino_id = o.casino_idWHERe game_start between dateadd(mi, -180, getdate()) and dateadd(mi, -5, getdate()) and b.[status] <> 'P' AND NOT EXISTS (SELECt *FROM thirdpartysettlecalled tpWHERe tp.[status] = 'Y' AND tp.casino_id = o.casino_id AND tp.game_id = g.game_id)ORDER BY casino_id
之后,检查您的索引或课程…
这也是EXCEPT的一个很好的用法(ORDER BY像UNIOn一样结束了:感谢@Damien_The_Unbeliever)
SELECt distinct o.casino_id, g.game_idFROM game g INNER JOIN Bet b ON g.game_id = b.game_id INNER JOIN CasinoUser u ON b.user_id = u.user_id INNER JOIN onewalletcasino o ON u.casino_id = o.casino_idWHERe game_start between dateadd(mi, -180, getdate()) and dateadd(mi, -5, getdate()) and b.[status] <> 'P'EXCEPTSELECt tp.casino_id, tp.game_idFROM thirdpartysettlecalled tpWHERe tp.[status] = 'Y'ORDER BY casino_id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)