Question

Write code in SQL. Q1) By looking at city table. Write a query that identify the...

Write code in SQL.

Q1) By looking at city table.

Write a query that identify the in how many cities the company has branches. Rename the column name to TotalNumberOfCities.
You have to look at city table and write a query to count number of rows.

Q2) By looking at film table.

How many films we have that its description contains the word "Robot". Count number of films and rename the column to NumberofRobots
Q3) By looking at film table.
How many films we have that its description contains the word "Truman".

Count number of films and rename the column to NumberofTruman

Q4) By looking at film table.

How many films we have that its description contains the word “ Robot” or "Truman". Count number of films and rename the column to RobotORTruman

Q5) By looking at film table.

How many films we have that its description contains the word “ Robot” and "Truman". Count number of films and rename the column to RobotANDTruman

Q6) By looking at film table.

Group film by special_features and count how many films are in each special features. Rename the column to NumberofFilms

Q7) By looking at film table.

Order query 6 by NumberofFilms in descending format.

Homework Answers

Answer #1

Please find the query as below:

Q1) SELECT COUNT ( DISTINCT branch ) AS 'TotalNumberOfCities' FROM city;

Q2) SELECT COUNT (*) AS 'NumberOfRobots' FROM film WHERE description LIKE '%Robot%' ;

Q3) SELECT COUNT (*) AS 'NumberOfTruman' FROM film WHERE description LIKE '%Truman%' ;

Q4) SELECT COUNT (*) AS 'RobotORTruman' FROM film WHERE description LIKE '%Robot%' or description LIKE '%Truman%';

Q5) SELECT COUNT (*) AS 'RobotANDTruman' FROM film WHERE description LIKE '%Robot%'  AND description LIKE '%Truman%';

Q6) SELECT COUNT(special_feature) AS 'NumberOfFilms'
FROM film
GROUP BY special_feature;

Q7) SELECT COUNT(special_feature) AS 'NumberOfFilms'
FROM film
GROUP BY special_feature ORDER BY DESC;

Note:Please replace the Table and Column Names with your respective Table and Column names.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider Sakila Database. Write a query in mySQL workbench to answer each of following questions. Q1)...
Consider Sakila Database. Write a query in mySQL workbench to answer each of following questions. Q1) By looking at city table. Write a query that identify the in how many cities the company has branches. Rename the column name to TotalNumberOfCities. You have to look at city table and write a query to count number of rows. Q2) By looking at film table. How many films we have that its description contains the word "Robot". Count number of films and...
Write a SQL statement which joins the parts table with the supplier table and lists the...
Write a SQL statement which joins the parts table with the supplier table and lists the part_name, supplier_name for all parts in the part table. The supplier_id column in the suppliers table is the primary key in the suppliers table, and this key has been exported to the parts table where it is a foreign key. You should use an inner join for this query. Write a SQL statement which joins the parts table with the suppliers table and lists...
PS8 JULY 1. Log on to your Oracle ApEx account. Navigate to SQL Workshop à SQL...
PS8 JULY 1. Log on to your Oracle ApEx account. Navigate to SQL Workshop à SQL Scripts Create a SQL script called update_demo_orders that contains these update statements: update demo_orders set order_total = 200 where customer_id = 1; update demo_orders set order_total = 15 where customer_id = 2; update demo_orders set order_total = 12 where customer_id = 3; update demo_orders set order_total = 22 where customer_id = 4; update demo_orders set order_total = 32 where customer_id = 5; update demo_orders...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s...
Write a script to create the following tables with attributes as specified(SQL) Customer table with Customer’s id, name, address, city as varchar, customer’s date of birth as date type and zip code number where the customers id is the primary key in the table, name and date of birth are mandatory. Id has a 10-character limit, name, address and city have a 50-character limit, zip has a 5-character limit Product Table with Product id, description and finish as varchar, price...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the below Relational Database. • Regarding the SQL queries: • Do not use SELECT * in any query. • Do not use any SQL features (including Nullif) that were not covered in this course. • Do not use subqueries IF joins can be used to answer a question. However, some questions may require the use of subqueries. The Movie Database Notes: TheaterNum, MovieNum, and ActorNum...
CREATE TABLE Customers (Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Address VARCHAR2(20), City...
CREATE TABLE Customers (Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Address VARCHAR2(20), City VARCHAR2(12), State VARCHAR2(2), Zip VARCHAR2(5), Referred NUMBER(4), Region CHAR(2), Email VARCHAR2(30), CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#), CONSTRAINT customers_region_ck CHECK (region IN ('N', 'NW', 'NE', 'S', 'SE', 'SW', 'W', 'E')) ); CREATE TABLE Orders (Order# NUMBER(4), Customer# NUMBER(4), OrderDate DATE NOT NULL, ShipDate DATE, ShipStreet VARCHAR2(18), ShipCity VARCHAR2(15), ShipState VARCHAR2(2), ShipZip VARCHAR2(5), ShipCost NUMBER(4,2), CONSTRAINT orders_order#_pk PRIMARY KEY(order#), CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#) REFERENCES customers(customer#)); In...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
Class-In Assignment 3: Chapters 4&5 How to retrieve data from two or more tables Exercises 1....
Class-In Assignment 3: Chapters 4&5 How to retrieve data from two or more tables Exercises 1. Write a SELECT statement that returns all columns from the Vendors table inner-joined with all columns from the Invoices table. 2. Write a SELECT statement that returns four columns: vendor_name vendor_name from the Vendors table invoice_number invoice_number from the Invoices table invoice_date invoice_date from the Invoices table balance_due invoice_total minus payment_total minus credit_total from the Invoices table The result set should have one row...
SQL Write the queries necessary to obtain the required information 1) Use sub query and “in”...
SQL Write the queries necessary to obtain the required information 1) Use sub query and “in” keyword to print the salesreps (ids) who have taken order for the companies ‘Zetacorp’ or ‘JCP Inc.’ . Duplicate rows are not allowed 2) Use sub query to find the id and the name of every sales rep that represents at least one customer with a credit limit of greater than $5000. 3) Use sub query and keyword “exists” to list the id and...
Q1. Which of the following statements are false ? (a) Inside, outside and boundary are basic...
Q1. Which of the following statements are false ? (a) Inside, outside and boundary are basic topological operations. (b) 9-intersection model formalizes binary topological relationship. (c) Topological relationships change under elastic deformation. (d) Direction (e.g., North, left) is a topological relationship. Q2. Which of the following is not a topological query ? (a) Which country has highest number of neighboring countries? (b) List airports within 100 miles of Chicago, Illinois. (c) Which rivers flow via at least six countries? (d)...