统计并显示SQL中数据的次数
count and display how many times data in SQL
我有一个tablelike.count显示多少次数据
SQL> select * from COUNT_TEST;
NAME ID
-------------------- ---------
A 4
B 3
C 2
D 1
我想要这样的输出:
name id
A 4
A 4
A 4
A 4
B 3
B 3
B 3
C 2
C 2
D 1
提前致谢。
with COUNT_TEST(NAME, ID) as(
select 'A',4 from DUAL union all
select 'B',3 from DUAL union all
select 'C',2 from DUAL union all
select 'D',1 from DUAL
)
select NAME, ID
from COUNT_TEST
connect by NAME=prior NAME and level<=ID
and prior DBMS_RANDOM.value is not null;
这是一个Rextester。
我有一个tablelike.count显示多少次数据
SQL> select * from COUNT_TEST;
NAME ID
-------------------- ---------
A 4
B 3
C 2
D 1
我想要这样的输出:
name id
A 4
A 4
A 4
A 4
B 3
B 3
B 3
C 2
C 2
D 1
提前致谢。
with COUNT_TEST(NAME, ID) as(
select 'A',4 from DUAL union all
select 'B',3 from DUAL union all
select 'C',2 from DUAL union all
select 'D',1 from DUAL
)
select NAME, ID
from COUNT_TEST
connect by NAME=prior NAME and level<=ID
and prior DBMS_RANDOM.value is not null;
这是一个Rextester。