2011-10-01 55 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

如果可能,我會將數據庫中的數據加載到前端,並在那裏更改表示。

相關問題