select *,[顯示]=case when a>=b then 'Y' else 'N' end from Table
SQL> select * from t; ID A B --------------------------------------- ----------- ----------- 1 9/10/08 9/11/08 2 9/11/08 9/10/08 3 9/12/08 9/12/08SQL> select id,a,b,case when a>=b then 'Y' else 'N' end compareResult from t; ID A B COMPARERESULT --------------------------------------- ----------- ----------- ------------- 1 9/10/08 9/11/08 N 2 9/11/08 9/10/08 Y 3 9/12/08 9/12/08 Y
SQL> select * from t; ID A B
--------------------------------------- ----------- -----------
1 9/10/08 9/11/08
2 9/11/08 9/10/08
3 9/12/08 9/12/08SQL> select id,a,b,case when a>=b then 'Y' else 'N' end compareResult from t; ID A B COMPARERESULT
--------------------------------------- ----------- ----------- -------------
1 9/10/08 9/11/08 N
2 9/11/08 9/10/08 Y
3 9/12/08 9/12/08 Y