SQL Queries
1. List book code, book title whose type is HOR
SELECT book_code, title FROM Book WHERE type='HOR';
2. List book code, book title whose type is HOR or with publisher code SC
SELECT book_code, title FROM Book WHERE type='HOR' OR publisher_code = 'SC';
3. List book code, book title whose type is MYS and price < 20
SELECT book_code, title FROM Book WHERE type='MYS' AND price < 20;
4. List book code, book title, price and increase the price by 20%.
=> Alter the table and add a column which will store the updated price.
ALTER TABLE Book ADD COLUMN Increased_price float(5,2);
UPDATE Book SET Increased_price = price + price*0.2;
SELECT book_code, title, price, Increased_price FROM Book
5. List books whose type is FIC, SFI or HOR
SELECT * FROM Book WHERE type IN ( 'FIC', 'SFI', 'HOR'); ----- using IN
SELECT * FROM Book WHERE type = 'FIC' or type = 'SFI' or type = 'HOR'); ----- without IN
6. List books whose publisher code not JP
SELECT * FROM Book WHERE publisher_code NOT IN ('JP');
7. List books whose price greater than or equal to 10, lesser than or equal to 20
SELECT * FROM Book WHERE price BETWEEN 10 AND 20; -------------- using BETWEEN
SELECT * FROM Book WHERE (price = 10 OR price > 10) AND (price = 20 OR price < 10); ---- without BETWEEN
8. List book title which has 'and'
SELECT title FROM Book WHERE title LIKE '%and%';
9. List publisher code, name, city and sort them by publisher code within city
SELECT * FROM Publisher GROUP BY City ORDER BY Publisher_code;
10. List book title, publisher code, type of paperback book and sort them on publisher code
SELECT title, publisher_code, type FROM Book WHERE paperback='Y' ORDER BY Publisher_code;
are Each question is worth 10 points. apply 1. List the book code and book title...
are Each question is worth 10 points. apply 1. List the book code and book title of each book that has the type HOR 2. List the book code and book title of each book that has the type HOR or is published by the publisher with the publisher code SC 3. List the book code and book title of each book that has the type MYS and a price of less than $20 4. List the book code, book...
How would you use this stored procedure to change the price of any copy of book 0180 whose format is paperback to $10.95? using MYSQL 8.0 Command line Client This is the database script for the homework above CREATE DATABASE HENRY; USE HENRY; CREATE TABLE AUTHOR (AUTHOR_NUM DECIMAL(2,0) PRIMARY KEY, AUTHOR_LAST CHAR(12), AUTHOR_FIRST CHAR(10) ); CREATE TABLE BOOK (BOOK_CODE CHAR(4) PRIMARY KEY, TITLE CHAR(40), PUBLISHER_CODE CHAR(3), TYPE CHAR(3), PRICE DECIMAL(4,2), PAPERBACK CHAR(1) ); CREATE TABLE BRANCH (BRANCH_NUM DECIMAL(2,0) PRIMARY KEY,...
MYSQL: Question: 1.Using a function, what are the lowest price books found in paperback? Only return the lowest price books. Display the book code as ‘Book Code’, the book title as ‘Title’, author name concatenated (first last) as ‘Author Name’ and price as ‘Price’. Insert your snip of the query and resultset together here. 2. Display the number of publishers by city. Display the city as ‘City’ and the number of publishers in that city as ‘Number of Publishers’. Insert...
MYSQL Questions: 1.For every author, display the number of books written by that author that is carried by Henry Books. Display the author number as ‘Author Number’, author name concatenated (first last) as ‘Author Name’, and the total number of books written by the author as ‘Number of Titles by Author’. List in descending order by author number. Limit the output to 10 rows. Insert your snip of the query and resultset together here. 2.Using a function, what are the...
1. Do a listing that represents the entities and attributes in the Book List. Select or create an appropriate primary key column for each entity. Make sure your data is atomic. List at least three entities: Book, Author, and Publisher. *PLEASE NOTE: I want a listing of the attributes that you think should be there (e.g. columns split up for atomicity, surrogate keys, etc.) *PLEASE NOTE AS WELL: You have to store all of the information from the original list...
Partial Question 10 1/2 pts Give the SQL statement to list the trip name and state for each trip that occurs during one of the Fall seasons that is Early Fall, Spring and Late Fall. Sort by State. Use the wildcard for the season. SELECT TripName, State FROM Trip WHERE Season LIKE '%Fall' OR SEA ORDER BY State: Answer 1: LIKE '%Fall' OR SEASON LIKE 'Spring' Answer 2: ORDER BY Partial Question 11 1/2 pts Give the SQL statement to...