在表中有一个名为 status 的列,它可以有 1 或 2。现在我想选择这样的模式
First Row 1
Second Row 2
Third Row 1
Fourth Row 2
......
在表中有一个名为 status 的列,它可以有 1 或 2。现在我想选择这样的模式
First Row 1
Second Row 2
Third Row 1
Fourth Row 2
......
对于偶数行
select * from emp where rowid%2 = 0;
对于奇数行
select * from emp where rowid%2 != 0;
SELECT * from
( SELECT a1.*,rank() over (partition BY status order by rownum) RNK FROM TABLE1 a1
)
ORDER BY rnk,status
select t1.*, (RN % 2)+1 as [STATUS] from
(
select t.*, ROW_NUMBER() OVER (ORDER BY <ORDER COLUMN NAME HERE>) as RN
) t1
尝试这个
select * from (select table.* ,rownum k from table) where mod(k,2)<>0;
尝试这个:
SELECT e1.* FROM Employee e1
INNER JOIN
(
Select e2.*, ROW_NUMBER() OVER (ORDER BY <Column Names>) AS RN FROM Employee e2
)E2
ON e1.eid=e2.eid
where e2.RN%2=0
要获取 ODD 记录,请使用以下内容:
SELECT e1.* FROM Employee e1 INNER JOIN
( Select e2.*, ROW_NUMBER() OVER (ORDER BY ) AS RN FROM Employee e2 )E2 ON e1.eid=e2.eid where e2.RN%2=1