posts - 431,  comments - 344,  trackbacks - 0
          1連接列值
          使用concat函數連接來自多個列的數值. 在DB2, Oracle和PostgreSQL中,"||"是concat函數的簡寫方式,"+"是SQL Server中的簡寫方式.
          select name||' is a '||type as msg from animal where ...
          select name+' is a '+type as msg from animal where...
          select concat(name, ' is a ', type) as msg from animal where ...

          2.在SELECT語句中使用條件邏輯
          case表達式可以針對查詢的返回值執行條件邏輯. 可以給case表達式取別名, 使結果集更易讀. else子句是可選的, 如果沒有使用else, 對于不滿足判斷條件的行, case表達式會返回NULL.
          select ename, sal,
             case when sal<=2000 then 'UNDERPAID'
             case when sal>=4000 then 'OVERPAID'
                    else 'OK'
             end as status
          from emp
          posted on 2008-07-14 21:16 周銳 閱讀(1558) 評論(0)  編輯  收藏 所屬分類: MySQLOracleSQL Server
          主站蜘蛛池模板: 宁津县| 神农架林区| 福泉市| 宁国市| 古丈县| 呼伦贝尔市| 忻城县| 黄大仙区| 靖远县| 阳江市| 商洛市| 辽源市| 太仓市| 浮梁县| 铜陵市| 大港区| 宣武区| 博兴县| 临沧市| 长沙县| 遂溪县| 孟连| 台北市| 安西县| 澄江县| 固始县| 永济市| 高雄市| 博兴县| 三台县| 邓州市| 五台县| 德州市| 威远县| 佛教| 新巴尔虎右旗| 都安| 富阳市| 长丰县| 乌什县| 东乌|