Re: [SQL ] 查詢請教

看板Database作者 ( Dizzy)時間14年前 (2011/05/16 13:54), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串3/3 (看更多)
Select * from employee where ssn not in (select superssn * from employee); 這樣就對了…只是 當初superssn 有一筆是null 所以怎麼都跑不出正確結果來 加了一個條件就完全正確了 select * from emplyee where ssn not in (select superssn * from employee where suprssn is not null) ※ 引述《tedcat (動靜:MSN暱稱為主)》之銘言: : : Employee(name,ssn,bdate, address, sex, salary,superssn) : : 例: : : name ssn bdate add sex salary superssn : : select avg(salary) from employee 這樣會把主管的薪水也算進去 : : 請問該怎麼做呢?是SQLplus : : 謝謝大大 : 我不確定你後來怎麼解決的... : 但是要找出不是主管的員工, : select * from employee : where : ssn not in (select superssn from employee) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 27.33.3.74

05/16 20:04, , 1F
superssn是空的那位仁兄應該是董事長吧
05/16 20:04, 1F
文章代碼(AID): #1DqBmE1r (Database)
文章代碼(AID): #1DqBmE1r (Database)