日期:2014-05-17  浏览次数:20872 次

紧急求救横列数据动态生成
现有表如下
视图1serviceorder
各列分别为  
ordertype   ordertypename   accounttype   accounttypename   num
1 会诊服务 1 白金卡           23
1 会诊服务 2 外服卡           10
1 会诊服务 3 体验卡 7
2 病后跟踪                 1               白金卡 14
3 特种检查                 2 外服卡                 85
group   by   前面四列,后面的num为统计数据

表1   ordertype
ordertype   ordertypename
1 会诊服务
2 病后跟踪
3 特种检查
4                               投诉申请

表2   accounttype
accounttype   accounttypename
1                           白金卡
2                           外服卡
3                           体验卡
4                           百医通卡


现在要求组成数据如下
ordertype     ordertypename             accounttype1   accounttypename1   num1   accounttype2   accounttypename2   num2   accounttype3   accounttypename3     num3     accounttype4   accounttypename4   num4    
1 会诊服务               1                       白金卡             23                   2               外服卡                   10           3                             体验卡                 7             4                               百医通卡           0            
2 病后跟踪
3 特种检查
4                               投诉申请

也就说,横和列的个数分别是跟据表1和表2动态生成的,排版有问题,不好意思,它自动换行了.


用什么方法都行,能达到这个效果就好.谢谢

------解决方案--------------------
学习学习。
------解决方案--------------------
行列转换
http://www.linuxmine.com/49751.html
------解决方案--------------------
关于多表结合行列转换,可以参考我写过的这个语句:
http://community.csdn.net/Expert/topic/5319/5319617.xml?temp=.9855921