1

表A

柱子   
---------
   一个
   乙            
   C
   :
   :
   Z

这是选择偶数行的方法。我写了一个这样的查询

select * from (select row_number()over(order by no asc ) as number   
  from number 
 where mod(number,2)=0)as even 

它不工作。

4

4 回答 4

2

尝试

select *  
  from 
(
  select *, row_number() over (order by columna) as rnum   
    from tablea
) q
 where mod(rnum, 2) = 0

输出:

| 否 | 随机数 |
|----|--------|
| 乙| 2 |
| D | 4 |
| F | 6 |

这是SQLFiddle演示

于 2013-10-07T06:46:33.170 回答
0
WITH cte AS(
    SELECT *
    ,      ROW_NUMBER()OVER(ORDER BY no)AS RowNum
    FROM number t
)
SELECT cte.* FROM cte
WHERE  mod(RowNum,2) = 0
于 2013-10-07T06:45:56.080 回答
0
SQL> desc member_list
 Name                            Null?    Type
 ------------------------------- -------- ----
 E_MAIL                                   VARCHAR2(50)
 NAME                                     VARCHAR2(50)


select e_mail from (select rownum row_num, e_mail from member_list)
where mod(row_num,2) = 0 -- EVEN

给你一个例子试试这个

于 2013-10-07T06:42:05.473 回答
0

不知道 abt postgres 但在 oracle 中你可以这样做

SELECT * FROM   
    (SELECT columna, ROWNUM RNUM  
            FROM tableA 
            ORDER BY columna)   
    where MOD(RNUM,2)=0
于 2013-10-07T07:03:00.273 回答