当前位置: 代码迷 >> PB >> 怎样把一个列分成两排显示解决方案
  详细解决方案

怎样把一个列分成两排显示解决方案

热度:25   发布时间:2016-04-29 10:10:21.0
怎样把一个列分成两排显示
有一个表 tb_wp ,存放物品名称 wpmc

现在需要打印出来物品列表 ,一列打印的太浪费,所以想分两列打印

类似这样的效果,每列显示25个

序号 物品 序号 物品
1 aaa 26 2sdf
2 aa 27 sdf
3 131 28 1sdf
4 112 29 3sdf
5 sdf 30 dfdf
6 sdf 31 458



25 sdfsd 50 1212 

--------------

或者这样的也可以

序号 物品 序号 物品
1 aaa 2 2sdf
3 aa 4 sdf
5 131 6 1sdf
7 112 8 3sdf



49 sdfsd 50 1212 


-----------------

求各位达人给指条明路,我只想到一个笨办法

生成一个四列的数据窗口,插入25条空行,然后依次把数据填里面,但是感觉这个方法有点笨。


请各位达人给我指一条更好的方法

------解决方案--------------------
用N_up格式的数据窗口试试
------解决方案--------------------
n_up类型
------解决方案--------------------
--如果你的序号连续

select max(case (序号 - 1) %2 when 0 then 序号) 序号1,
max(case (序号 - 1) %2 when 0 then 物品) 物品1,
max(case (序号 - 1) %2 when 1 then 序号) 序号2,
max(case (序号 - 1) %2 when 1 then 物品) 物品2
from tb group by (序号 - 1) / 2

--如果你的序号不连续
select max(case (px - 1) %2 when 0 then 序号) 序号1,
max(case (px - 1) %2 when 0 then 物品) 物品1,
max(case (px - 1) %2 when 1 then 序号) 序号2,
max(case (px - 1) %2 when 1 then 物品) 物品2
from (select t.* , px = (select count(1) from tb where 序号 < t.序号) + 1 from tb t) m
group by (px - 1) / 2

--如果sql 2005或oracle。
select max(case (px - 1) %2 when 0 then 序号) 序号1,
max(case (px - 1) %2 when 0 then 物品) 物品1,
max(case (px - 1) %2 when 1 then 序号) 序号2,
max(case (px - 1) %2 when 1 then 物品) 物品2
from (select t.* , row_number() over(order by 序号) px from tb t) m
group by (px - 1) / 2

 
对上述语句做成动态窗口,或是做成动态窗口后,再把数据导入到一个你已经做成报表的数据窗口中去.
------解决方案--------------------
学习 。。。。。。。
------解决方案--------------------
学习 。。。。。。。
------解决方案--------------------
学习了....
  相关解决方案