Skip to content

Tag: split

Split multiple strings in SQL

I am trying to split multiple columns of strings at the same time. My original data looks like: Table1 UserID Type ProductID 1 A, B 001, 003 and I want to end up with UserID Type ProductID 1 A 001 1 B 003 When I use I end up with this table that I do not want… UserID Type ProductID

How to create table from an existing table

I’m in Oracle APEX and would like to create a new table from other existing one like this: I have a column in a SONGS table that is: ARTIST NAME Another header Bad Bunny row Bad Bunny, Ozuna, Daddy Yankee row And I want this in another table: ID Artist 1 Bad Bunny 2 Ozuna 3 Daddy Yankee Also, from

Splitting strings in SQLite

Does anyone know how to split my address columns. I would like to divide it into three new columns, seperated by it’s commas. For example 1808 FOX CHASE DR, GOODLETTSVILLE, TN is divided into 1808 FOX CHASE DR GOODLETTSVILLE TN So far I’ve tried Although I cannot create the third column with the s…

SQL query to split and keep only the top N values

I have the following table data: I need to create a table with a split items column, but with the limitation to have at most N items per name. E.g. for N = 3 the table should look like this: 
I have the following query that splits items correctly, but doesn’t account for the maximum number N. What shoul…

Postgres: Split column values & transpose

I have a table like this: And I want to convert it to this: I have tried splitting the column based on ; but the product_id count varies based on the category_id. Is there anyway I can achieve this? Answer You can use PostgreSQL’s array manipulation functions: string_to_array does exactly what it says —…