星期五, 4月 15, 2005

 

SQL啊, 我敗給祢了 orz


今天Database Lab,對着一條這樣棘手的題目,我敗了 orz
Find all pairs of employees who have the same monthly salary. For each pair of them, list their numbers, names, and salaries. Note that each pair should only be listed once

出來的結果卻只能做成這樣...
SQL> SELECT DISTINCT e.empno,e.ename,e.sal,se.empno,se.ename,se.sal FROM EMP e, EMP se
  2  WHERE e.sal = se.sal
  3  AND NOT e.empno=se.empno;

     EMPNO ENAME             SAL      EMPNO ENAME             SAL
---------- ---------- ---------- ---------- ---------- ----------
      7654 MARTIN           1250       7521 WARD             1250
      7521 WARD             1250       7654 MARTIN           1250
      7902 FORD             3000       7788 SCOTT            3000
      7788 SCOTT            3000       7902 FORD             3000

SQL>


面對這應該如此卻出不到的結果......
     EMPNO ENAME             SAL      EMPNO ENAME             SAL
---------- ---------- ---------- ---------- ---------- ----------
      7654 MARTIN           1250       7521 WARD             1250
      7902 FORD             3000       7788 SCOTT            3000


我真的敗給祢了 orz

標籤:


留言


發佈回應

發佈留言

留不了言?試試在這裡留吧。
回首頁