select top 1 a.id,b.id
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
where a.id <(select min(a.id) --这里为什么不能用a.id 啊。
from
(select top 2 a.id
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
order by a.id desc) as tblTmp)
order by a.id desc解决一下啊
无法绑定由多个部分组成的标识符 "Authentication.id"。
那么就要
select top 1 a.id,b.id from (
select *
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2 ) d然后用 d.id 就行了...
select top 5 a.id,b.id
from Company as a,Accountable as b
where a.id <(select min(a.id)--还是一样啊
from (select top 5 a.id
from Company as a,Accountable as b
where a.id=b.CompanyID and b.Authentication=2
order by a.id desc) as tblTmp) and a.id=b.CompanyID and b.Authentication=2
order by a.id desc。
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
where a.id <(select min(tblTmp.id) --注意:from里面的表名此时是tblTmp
from
(select top 2 a.id as id --这里加个列名
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
order by a.id desc) as tblTmp)
order by a.id desc
select top 1 a.id,b.id
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
where a.id <(select min(Company.id) --这里为什么不能用a.id 啊。
from
(select top 2 Company.id
from Company inner join Accountable
on Company.id=Accountable.CompanyID and Accountable.Authentication=2
order by Company.id desc) as tblTmp)
order by a.id desc
无法绑定由多个部分组成的标识符 "Company.id"。
select min(a.id) --这里为什么不能用a.id 啊。
from
(select top 2 a.id
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
order by a.id desc) as tblTmp) a
这样可以吧。因为你查询的是(select top 2 a.id
from Company as a inner join Accountable as b
on a.id=b.CompanyID and b.Authentication=2
order by a.id desc) as tblTmp)这个作为一个整体看。