-4
注意(DEPTID = 2,3)或(DEPTID = 1,總和(總擁有成本)= 0)集團通過並具有OR條件在SQL Server
select *
into employee1
from employee2
where empid in (select distinct empid
from employee3 e3
join employee2 e2 on e3.empid = e2.empid
where e3.deptid in (2,3)
or (e3.deptid = 1
group by empid, cost
having sum(e2.cost) = 0))
什麼是你的問題? –
查詢有幾個錯誤..'(e3.deptid = 1'沒有緊密的圓括號,並且由xxxx'組沒有字段。 –
實際上我想實現像下面這樣的條件..(deptid = 2,3)或者(deptid = 1且總和(總成本)= 0).....................成本欄屬於employee3並且deptid屬於employee2 –