0

我想转换这个查询:

SELECT *
FROM   myTable
WHERE   dateCreated = (
                       SELECT MAX(dateCreated)
                       FROM   myTable
                      )
      AND duty IS NULL
      AND CompanyPayingId   IN 
                                  (43081 ,43082 ,43084 ,43085)

从更改inExists查询(由于性能):

但是我在转换代码时遇到了麻烦,因为我认为我必须复制where子句......

如何转换此代码?

4

1 回答 1

1

我可以这样做:

create table num(idn int)
insert into num values(43081) ,(43082),(43084) ,(43085)
select * from num
SELECT *
FROM   myTable m inner join num n
ON  m.dateCreated = (SELECT MAX(dateCreated) FROM   myTable)
      AND m.duty IS NULL
      AND m.CompanyPayingId=n.num
于 2012-08-06T08:28:36.650 回答