做报表有时数据没有关联关系,需要构造一列来做为关联关系,这时可以做一个临时表或者构造一个结果集。
临时表就说了。下面说下如果数据量大怎么在excel里做一个结果集:
构造方式是这个:
select ‘50637333’way_no ,’红河金平县’way_Name, ‘W00’way_code from dual union all
select ‘50860963’,’安徽芜湖’, ‘W060601’ from dual union all
select ‘5037876’,’湛江麻章区东海岛’, ‘W52’ from dual union all
select ‘5097877’,’湛江麻章区东海岛’, ‘W0002’ from dual
数据量大可以在excel中使用
公式:=”’”&E1&”’,’”&F1&”’,’”&G1&”’”
之后拷贝出来即可(去掉最后一个union all)
select ‘wrewe’,’4566’,’ty433’ from dual union all
select ‘wrewe’,’4566’,’ty434’ from dual union all
select ‘wrewe’,’4566’,’ty435’ from dual union all
select ‘wrewe’,’4566’,’ty436’ from dual union all
select ‘wrewe’,’4566’,’ty437’ from dual union all
select ‘wrewe’,’4566’,’ty438’ from dual union all
select ‘wrewe’,’4566’,’ty439’ from dual union all
select ‘wrewe’,’4566’,’ty440’ from dual union all
select ‘wrewe’,’4566’,’ty441’ from dual union all
select ‘wrewe’,’4566’,’ty442’ from dual union all
select ‘wrewe’,’4566’,’ty443’ from dual union all
select ‘wrewe’,’4566’,’ty444’ from dual union all
select ‘wrewe’,’4566’,’ty445’ from dual union all
select ‘wrewe’,’4566’,’ty446’ from dual union all
select ‘wrewe’,’4566’,’ty447’ from dual union all
select ‘wrewe’,’4566’,’ty448’ from dual union all
select ‘wrewe’,’4566’,’ty449’ from dual union all
select ‘wrewe’,’4566’,’ty450’ from dual union all
select ‘wrewe’,’4566’,’ty451’ from dual union all
select ‘wrewe’,’4566’,’ty452’ from dual union all
select ‘wrewe’,’4566’,’ty453’ from dual union all
select ‘wrewe’,’4566’,’ty454’ from dual union all
select ‘wrewe’,’4566’,’ty455’ from dual union all
select ‘wrewe’,’4566’,’ty456’ from dual union all
select ‘wrewe’,’4566’,’ty457’ from dual union all
select ‘wrewe’,’4566’,’ty458’ from dual union all
select ‘wrewe’,’4566’,’ty459’ from dual
针对单行数据也可以使用:
SELECT REGEXP_SUBSTR(‘1,2,3,4,5,6,7,8,9’, ‘[^,]+’, 1, ROWNUM)aa FROM DUAL CONNECT BY ROWNUM <= LENGTH(‘1,2,3,4,5,6,7,8,9’) - LENGTH(REPLACE(‘1,2,3,4,5,6,7,8,9’, ‘,’, ”)) + 1这种语句
解读这个语句:(分解语句)