posts - 188,comments - 176,trackbacks - 0

          1.SQL SERVER  是用先逆序再正序的方法

          select top 3 * from (select top 9 * from mvc_book order by bid) as s order by s.bid desc [第6,5,4條]

          select * from (select top 3 * from (select top 6 * from mvc_book order by bid) as s order by s.bid desc) as s1 order by s1.bid  [第4,5,6條]

          select top 6 * from mvc_book where (bid not in (select top 2 bid from mvc_book))[第3,4,5,6,7,8條]
           

          2.ORACLE 用Minus和Rownum來實現 (Minus 減去  Union 聯合 Intersect 返回相同的記錄集)

          select * from t_service_vnet_send where rownum <= 15 MINUS select * from t_service_vnet_send where rownum <= 10;

          select * from (select rownum no,id,age,name from loaddata where rownum <= 3 ) where no >= 2;

          3.DB2
          select * from (select ROW_NUMBER() over() as a, org.* from org) as temp where a>=n1 and a<=n2

          4.MYSQL
          select * from tablename limit m,n;

          posted on 2009-01-30 20:36 cheng 閱讀(1305) 評論(0)  編輯  收藏 所屬分類: SQLServerOracle
          主站蜘蛛池模板: 松滋市| 中西区| 南靖县| 彝良县| 蓬安县| 遵化市| 政和县| 芦山县| 务川| 厦门市| 平武县| 芒康县| 石屏县| 镇沅| 乐亭县| 寻甸| 滦南县| 板桥市| 色达县| 韶山市| 四子王旗| 岢岚县| 广西| 望谟县| 东宁县| 正宁县| 朝阳区| 临沭县| 长海县| 博罗县| 喀喇| 湘潭县| 武威市| 仙游县| 黄平县| 玉龙| 张北县| 巨野县| 湘阴县| 水富县| 习水县|