SQL Language (MOSC)

MOSC Banner

Use of SQL PIVOT

Hello. I'm trying to use PIVOT to get a column-based result, not a row-based result.

This isn't the actual data source, but is being simplified to ask the question here.

This query works and produces 10 columns:


SELECT * 

FROM (SELECT lookup_code

    FROM fnd_lookups

    WHERE lookup_type = 'POS_BUSINESS_CLASSIFICATIONS'

   )

PIVOT (COUNT(lookup_code)

     FOR lookup_code

     IN ('000', '001', '002', '003', '004', '005', '006', '007', '008', '009')

   )

Multiple Oracle pages that I've looked at say you can replace that hardcoded list with the word any , or put it into a query. One such page is here:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center