Answer the question
In order to leave comments, you need to log in
Is it possible to somehow dynamically form a pivot?
Is it possible to somehow dynamically form what is after FOR IN ?
select * from (
select times_purchased as "Puchase Frequency", state_code
from customers t
)
pivot
(
count(state_code)
for state_code in ('NY' as "New York",'CT' "Connecticut",'NJ' "New Jersey",'FL' "Florida")
)
order by 1
'NY' as "New York",'CT' "Connecticut",'NJ' "New Jersey",'FL' "Florida"
I have them stored in a separate cities table , I can pull them out with select, so I don’t really want to write them explicitly in pivot. SELECT
LISTAGG( city , ',') WITHIN GROUP (ORDER BY ID) city
FROM cities
Answer the question
In order to leave comments, you need to log in
Not sure, but most likely not. Can be solved through dynamic sql.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question