Advice Using Pivot Table in Oracle

ghz 1years ago ⋅ 6428 views

Question

i need a report and i should use pivot table for it.Report will be group by categories .It is not good to use case when statement because there are many categories.u can think Northwind Database as sample and All Categories will be shown as Columns and Report will show customers preference among Categories.I dont know another solution and saw examples as Stored Procedures in Internet for Sql Server.Do u know a Solution except for using case when?

Thanks


Answer

Once you get Oracle 11G there is a [built-in PIVOT feature](http://www.oracle.com/technology/pub/articles/oracle- database-11g-top-features/11g-pivot.html). Prior to that, you are restricted to using CASE (or DECODE) expressions. I have an article on how to automate doing that [on my blog.](http://tonyandrews.blogspot.com/2004/10/pivot- queries.html)