-1
A
回答
1
這實際上是一個非支點,沒有支點
select year, week, 'loading' as area, loading as value
from the_table
union all
select year, week, 'picking', picking
from the_table
union all
select year, week, 'painting', painting
from the_table
+0
非常感謝你..救了我 – Anshul
0
如果只有3,您需要轉動柱子,然後用union
select year,week,'loading' as aread,loading as val from tbl
union all
select year,week,'painting' as area,painting as val from tbl
union all
select year,week,'picking' as area,picking as val from tbl
如果列的數量是動態的,那麼我建議你使用動態數據透視表。
Dynamic pivot query using PostgreSQL 9.3
http://www.cureffi.org/2013/03/19/automatically-creating-pivot-table-column-names-in-postgresql/
+0
謝謝你Utsav – Anshul
相關問題
- 1. 如何Postgres的
- 2. 如何在Postgres的
- 3. 如何在Postgres的
- 4. 如何Postgres的9
- 5. 如何從Postgres的功能
- 6. 如何檢查的Postgres裏
- 7. 如何使用Postgres的
- 8. 如何「名稱」中的Postgres
- 9. 如何調用Postgres的
- 10. 如何查詢postgres的UUID
- 11. 如何創建與Postgres的
- 12. 如何插入'到postgres?
- 13. 如何解析了在Postgres
- 14. 如何設置Postgres擴展?
- 15. 如何保持jdbc postgres alive
- 16. 如何去除postgres中的大對象
- 17. 的Postgres如何保持使用CTE
- 18. Postgres的序列如何被打破?
- 19. 如何計算Postgres中的json數據
- 20. Postgres:如何獲得多列的聚合
- 21. 如何獲得調試postgres的權限?
- 22. 的Postgres 8.4.3:如何使用UNNEST
- 23. 如何Postgres的執行批量插入
- 24. 如何使用派生表中的Postgres
- 25. 如何刪除postgres中的約束?
- 26. 如何替換postgres中的表格?
- 27. Postgres的:如何從同一個表
- 28. 如何實現SQL(Postgres的)優先
- 29. 如何刪除Postgres的擴展
- 30. Postgres的 - 如何檢查空數組
http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking - 問題/ 285557#285557 –