2011-10-01 49 views
0

我的用户想要一个报告,在多行表中重复多行的行和列直到多行的所有行都完成。 什么是最好的方式来编写查询? 我希望能得到我想要的东西在一个报告中代表一对多关系,并且在一行中获取多个表而不是col

______________________________________________________________________________________ 
|table(1)  |    table(2)            | 
|---------------|--------------------|--------------------|------|--------------------| 
|table(1) (row1)|table(2 of 1)(row 1)|table(2 of 1)(row 2)| .... |table(N of 1)(row X)| 
|---------------|--------------------|--------------------|------|--------------------| 
|table(1) (row2)|table(2 of 2)(row 1)|table(2 of 2)(row 2)| .... |table(N of 2)(row y)| 
|---------------|--------------------|--------------------|------|--------------------| 
|table(1) (row3)|table(2 of 3)(row 1)|table(2 of 3)(row 2)| .... |table(N of 3)(row Z)| 
|---------------|--------------------|--------------------|------|--------------------| 
... 
... 
... 
+0

我真的不明白......你能举一个真实数据的例子吗? –

+0

@Mark Byers:我编辑它。谢谢 – Mohsen

回答

1

这些都是你需要的工具:

  1. 动态SQL
  2. 嵌套查询
  3. rownum功能
  4. case when

如果可能,我会将数据库中的数据加载到前端,并在那里更改表示。

相关问题