紧急求救横列数据动态生成,该怎么处理

紧急求救横列数据动态生成现有表如下视图1serviceorder各列分别为ordertypeordertypenameaccounttypeaccou

紧急求救横列数据动态生成
现有表如下
视图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