SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table tbl_ya ( YoungAdult_BookId int identity(1,1) NOT NULL primary key, Book_Title varchar(150) NOT NULL, Book_Author varchar(150), Book_Pages int, Published_Date datetime, Publishing_House varchar(150), Book_Ratings decimal(12,4), ); create table tbl_fiction ( FictionBook_Id int identity(1,1) NOT NULL primary key, Book_Title varchar(150) NOT NULL, Book_Author varchar(150), Book_Pages int, Published_Date datetime, Publishing_House varchar(150), Book_Ratings decimal(12,4), ); create table tbl_anthology ( Anthology_BookId int identity(1,1) NOT NULL primary key, Book_Title varchar(150) NOT NULL, Book_Author varchar(150), Book_Pages int, Published_Date datetime, Publishing_House varchar(150), Book_Ratings decimal(12,4), ); create table tbl_sales( sales_bookId int identity(1,1) NOT NULL primary key, Book_Title varchar(150) NOT NULL, store_sales int, ); INSERT INTO tbl_ya (Book_Title, Book_Author, Book_Pages, Published_Date, Publishing_House, Book_Ratings) VALUES('Thirteen Reasons Why', 'Jay Asher', '288', '2007-10-18 00:00:00', 'Penguin Young Readers', '4.7'), ('The Fault in Our Star', 'John Green', '313', '2012-01-10 00:00:00', 'Dutton Book', '4.2'), ('Youve Reached Sam', 'Dustin Thao', '304', '2021-11-09 00:00:00', 'St. Martins Publishing Group', '4.1'), ('All the Bright Places', 'Jennifer Niven', '388', '2015-01-06 00:00:00', 'Knopf Publishing Group', '4.1'), ('One of Us is Lying', 'Karen M. McManus', '268', '2017-05-29 00:00:00', 'Delacorte Press', '4.0'), ('They Both Die in the End', 'Silvera', '384', '2017-09-05 00:00:00', 'HarperTeen', '4.0'), ('Everything Everything', 'Nicola Yoon', '310', '2015-09-01 00:00:00', 'Delacorte Books', '4.0'), ('Red Queen', 'Victoria Aveyard', '388', '2015-02-10 00:00:00', 'HarperTeen', '4.0'), ('We Were Liars', 'E. Lockhart', '256', '2014-05-13 00:00:00', 'Delacorte Press', '3.8'), ('Paper Town', 'John Green', '305', '2008-10-16 00:00:00', 'Dutton Books', '3.8'); INSERT INTO tbl_fiction VALUES('Where the Crawdads Sing', 'Delia Owens', '368', '2018-08-14 00:00:00', 'G.P Putnams Son', '4.5'), ('It Ends with Us', 'Colleen Hoover', '376', '2016-08-16 00:00:00', 'Simon & Schuster', '4.4'), ('The Song of Achilles', 'Madeline Miller', '416', '2011-09-20 00:00:00', 'Eco Press', '4.4'), ('The Seven Husbands of Evelyn Hugo', 'Taylor Jenkins Reid', '400', '2017-06-13 00:00:00', 'Atria Books', '4.4'), ('All the Light We Cannot See', 'Anthony Doerr', '544', '2014-05-06 00:00:00', 'Simon & Schuster', '4.3'), ('Circe', 'Madeline Miller', '393', '2018-04-10 00:00:00', 'Bloomsburry Publishing', '4.3'), ('The Kite Runner', 'Khaled Hosseini', '371', '2003-05-29 00:00:00', 'Riverhead Books', '4.3'), ('People We Meet on Vacation', 'Emily Henry', '382', '2021-05-11 00:00:00', 'Barkley Publishing Corporation', '4.1'), ('The Midnight Library', 'Matt Haig', '304', '2020-08-13 00:00:00', 'Penguin Publishing Group', '4.1'), ('Normal People', 'Sailey Rooney', '266', '2018-08-28 00:00:00', 'Faber&Faber', '3.8'); INSERT INTO tbl_anthology (Book_Title, Book_Author, Book_Pages, Published_Date, Publishing_House, Book_Ratings) VALUES('The Things They Carried', 'Tim OBrien', '233', '2009-03-28 00:00:00', 'Riverhead Books', '4.1'), ('The Tales of Beedle and Bard', 'J.K. Rowling', '157', '2008-12-04 00:00:00', 'Bloomsburry Publishing PLC', '4.0'), ('All Out', 'Mackenzi Lee', '368', '2018-02-27 00:00:00', 'Harlequin Teen', '4.0'), ('Everything Eventual', 'Stephen King', '464', '2002-03-01 00:00:00', 'Scribner', '4.0'), ('Five Tuesday in Winter', 'Lily Kings', '240', '2021-11-09 00:00:00', 'Groove/ Atlanta Inc', '3.9'), ('Fragile Things', 'Neil Gailman', '400', '2021-08-13 00:00:00', 'William Morow', '3.9'), ('Her Body and Other Parties', 'Carmen Maria Mac', '264', '2017-10-03 00:00:00', 'Graywolf Press', '3.8'), ('Dangerous Women', 'George Martin', '784', '2013-11-27 00:00:00', 'Tor Books', '3.7'), ('My True Love Gave To Me', 'Stephanie Perkins', '3127', '2014-10-14 00:00:00', 'St. Martin Press', '3.7'), ('Zombie Vs Unicorn', 'Holly Black', '415', '2010-09-21 00:00:00', 'Margaret K. McElderly Book', '3.7'); INSERT INTO tbl_sales( Book_title,store_sales) VALUES('Thirteen Reasons Why', 1500), ('One of Us is Lying', 5000), ('The Fault in Our Star', 7000); SELECT publishing_House, avg(Book_Ratings) as stars FROM tbl_ya GROUP BY publishing_House go SELECT publishing_House, avg(Book_Ratings) as stars FROM tbl_ya GROUP BY publishing_House HAVING avg(Book_Ratings)> 4 go
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear