0

whats wrong in line 27? (it gives me a little error)

CREATE TABLE books(catalog TEXT , name VARCHAR(20), author VARCHAR(20), publisher VARCHAR(20) , year YEAR , pages INT , price DOUBLE , PRIMARY KEY(catalog)); insert into books values ('1234', 'War and Peace', 'Leo Tolstoy','Keshet', 1982, 1255, 102.5); insert into books values ('2365', 'Skeleton Crew','Stephen King', 'Harper Collins', 1986, 563, 86.99); insert into books values ('2233', 'Liseys Story','Stephen King', 'Penguin', 2006, 456, 88.0); insert into books values ('4455', 'Anna Karenina','Leo Tolstoy', 'Penguin', 2006, 963, 129.99); insert into books values ('4545', 'A Tale Of Love And Darkness','Amos Oz', 'Penguin', 1986, 850, 117.99); insert into books values ('1352', 'Desperation','Stephen King', 'Harper Collins', 2011, 365, 79.99); insert into books values ('8657', 'Harry Potter and the philosophers stone','J.K Rowling', 'Scholastic Press', 1997, 309, 72.23); insert into books values ('5754', 'The Wave','Todd Strasser', 'Dell', 1981, 146, 20.99); insert into books values ('9781', 'Percy Jackson','Rick Riordan', 'Disney Hyperion', 2005, 200, 59.99); insert into books values ('7825', '1984','George Orwell', 'Harvill Secker', 1949, 328, 36.80); insert into books values ('4376', 'The Lottery','Shirley Jackson', 'The New Yorker', 1948, 32, 20.04); after_discount DOUBLE = (price * 82) / 100; ALTER TABLE books ADD after_discount AFTER price; SELECT * FROM books;

11th Sep 2020, 1:00 PM
Yahel
Yahel - avatar
6 Answers
+ 1
Ipang , thanks! it's working great!
11th Sep 2020, 2:41 PM
Yahel
Yahel - avatar
0
Which line was that? the ALTER TABLE line or the line before it?
11th Sep 2020, 1:36 PM
Ipang
0
Ipang the line before that..
11th Sep 2020, 2:18 PM
Yahel
Yahel - avatar
0
yahel Try this, but replace the 2 lines before the SELECT * FROM books; with this. I haven't tested it but I hope it works. ALTER TABLE books ADD after_discount DOUBLE AFTER price; UPDATE books SET after_discount = (price * 0.82);
11th Sep 2020, 2:34 PM
Ipang
0
Glad to hear that yahel 👍
11th Sep 2020, 3:14 PM
Ipang
0
i have another question if you dont mind... i posted it.. you can go to my profile and get to my last discussion... thanks!
11th Sep 2020, 3:28 PM
Yahel
Yahel - avatar