I have a list of User IDs and product data (In Redshift), currently a row in the table has 1 userID and 1 product name. I need to change the table so that each user ID only appears once, and in that row is one column for each of the products purchased. I know I can use ListAGG to get a single column per user_ID for all the products in a list. Then how do I split that list into many columns? And is there a better way? Thanks in advance!
Please be aware that this is primarily a SQL Server forum. ListAGG is not part of SQL Server. Someone here may still be able to help you.
Assuming it's Oracle, which does have that function, here is a blog post with code examples that may help: https://blogs.oracle.com/sql/post/split-comma-separated-values-into-rows-in-oracle-database