oracle 数据库 查询40条数据 怎样让男女的数量各是20条

2025-03-03 22:15:31
推荐回答(1个)
回答1:

不太明白你的意思


假设你的查询语句为:

select * from ta where ...


看看这样是不是能行:

select
   case when aaa.rn between 1 and 20 then '男' else '女' end xb,
   aaa.*
from (select rownum rn, ta.* from ta where ...) aaa