SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
-- create table CREATE TABLE IF NOT EXISTS QT_Films ( id int NOT NULL AUTO_INCREMENT, year int(4) unsigned NOT NULL, title varchar(200) NOT NULL, company varchar(200) NOT NULL, PRIMARY KEY (id) ) DEFAULT CHARSET = utf8; INSERT INTO QT_Films (year,title,company) VALUES ('1992','Reservoir Dogs','Miramax'), ('1994','Pulp Fiction','Miramax'), ('1997','Jackie Brown','Miramax'), ('2003','Kill Bill: Volume 1','Miramax'), ('2004','Kill Bill: Volume 2','Miramax'), ('2007','Death Proof','Dimension Films'), ('2009','Inglourious Basterds','The Weinstein Company / Universal Pictures'), ('2012','Django Unchained','The Weinstein Company / Sony Pictures Releasing'), ('2015','The Hateful Eight','The Weinstein Company'), ('2019','Once Upon a Time in Hollywood','Sony Pictures Releasing'); -- create initial CTE WITH QTF AS (SELECT * FROM QT_Films), RMV_TWC AS ( SELECT year, title, TRIM(REPLACE((REPLACE(company,'The Weinstein Company','')),'/','')) AS company FROM QTF), -- remove The Weinstein Company QTF_RENAMED AS (SELECT year AS 'Year_Released', title AS 'Film_Title', RTRIM(company) AS 'Distributor' FROM RMV_TWC) -- rename columns -- select SELECT * FROM QTF_RENAMED;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear