Question

In: Computer Science

Using the following schema, write a SQL query to satisfy the question: What are the names...

Using the following schema, write a SQL query to satisfy the question: What are the names of the suppliers of 'Pith_helmet' sold in a department managed by 'Andrew'?

Schema:

Sale (saleno, saleqty, itemno, dname)

Supplier (splno, splname)

Item (itemno, itemname, itemtype, itemcolor)

Department (deptname, deptfloor, deptphone, empno)

Delivery (delno, delqty, itemnum, dptname, splno)

Employee (empno, empfname, empsalary, departname, bossno)

Solutions

Expert Solution

Coding

/* Drop existing table*/
drop table Sale;
drop table Supplier;
drop table Item;
drop table Department;
drop table Delivery;
drop table Employee;
/*Create new table */
create table Sale(saleno number(3), saleqty number(8), itemno number(5), dname varchar(20));
desc Sale;
create table Supplier (splno number(5), splname varchar(20));
desc Supplier;
create table Item (itemno number(3), itemname varchar(10), itemtype varchar(10), itemcolor varchar(10));
desc Item;
create table Department (deptname varchar(20), deptfloor number(2), deptphone number(10), empno number(5));
desc Department;
create table Delivery (delno number(3), delqty number(3), itemnum number(3), dptname varchar(20), splno number(5));
desc Delivery;
create table Employee (empno number(5), empfname varchar(20), empsalary number(10), departname varchar(10), bossno number(3));
desc Employee;

/*What are the names of the suppliers of 'Pith_helmet' sold in a department managed by 'Andrew'?*/

/*In this query we need to join Four table toghtehr Supplier ,Delivery,and Department,and iteam and it will return only splier name with approriate condition as we set */
Select Supplier.splname from Supplier inner join Delivery on Supplier.splno=Delivery.splno inner join Department on Department.deptname=Delivery.dptname inner join Item on Item.itemno=Delivery.itemnum where itemname='Pith_helmet' and Department.empno in(Select empno from Employee where empfname='Andrew');

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

In sql: Write a query to produce a listing of unique vendor names who have at...
In sql: Write a query to produce a listing of unique vendor names who have at least one invoice with us. You are using a table view called COMPANY_INFORMATION that lists a vendor id, vendor name, term id, and term description. The second table you will reference is the invoice table that lists vendor id, invoice num, invoice number, and invoice total. Do not show duplicate results.
SQL query exercises: Consider the following database schema:                Product(maker, model, type)              &
SQL query exercises: Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Consider the Drivers-Cars-Reserves DB for a small rental car company:                Drivers(id, name, rating, age)                Cars(vin, maker, model, year, color)                Reserves(did, vin, date) Give SQL statement each of the following operations: Find the colors of cars reserved by Smith. Find all id’s of drivers who have a...
How to write a query in SQL using the Group by function to decide if the...
How to write a query in SQL using the Group by function to decide if the results of the diet worked. There are 6 columns ID, Gender, treatment, start_weight_kg, end_weight_kg, and correct change (end weight minus start weight). With the information given write a SQL to determine if the the results(correct change) worked. Question is not incomplete.
B) DML and SQL Query For this DB Schema, answer the below questions: Employee (Fname, Minit,...
B) DML and SQL Query For this DB Schema, answer the below questions: Employee (Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno) Department (Dname, Dnumber, Mgr_ssn, Mgr_start_date) 5. Delete from Employee table, those who have First name: James. 6. Delete from Employee table, those who have Salary more than 4000. 7. What happens if you try to delete one department? 8. Retrieve the data of all employee. 9. Retrieve the data of all male employee. 10. Retrieve the...
Question: Write a single SQL query that, for each pair of actors, lists their two actor_ids...
Question: Write a single SQL query that, for each pair of actors, lists their two actor_ids and the number of films in which both actors appeared. DATABASE SCHEMA CREATE TABLE actor ( actor_id INTEGER, first_name TEXT, last_name TEXT); CREATE TABLE film ( film_id INTEGER, title TEXT, description TEXT, length INTEGER); CREATE TABLE film_actor ( actor_id INTEGER, film_id INTEGER);
Basic SQL Use the following schema to answer the queries below using SQL DEVICE [dno, dtype,...
Basic SQL Use the following schema to answer the queries below using SQL DEVICE [dno, dtype, price] PROVIDER [pno, pname, web] SERVICE [dno, pno, servicedate] SERVICE.dno references DEVICE.dno SERVICE.pno references PROVIDER.pno bold is underline. a) Find the dno for the most expensive device b) Find all providers that have the work fast in the name c) Find the number of different device types (dtype) d) Give all details of devices with price more than $400
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Describe in words what the function of each line is in the following SQL query The...
Describe in words what the function of each line is in the following SQL query The lyrics database is provided under question 3 for context 1. select studioID, studioname, base from salespeople sa inner join studios st on (sa.salesID = st.salesid) where base < 300 2. SELECT artistName FROM Artists WHERE artistID IN (SELECT artistID FROM Titles) 3. select m.lastname, m.firstname, s.lastname         from members m inner join salespeople s using (salesID)         order by m.lastname asc; The lyrics database...
Write SQL queries below for each of the following: List the names and cities of all...
Write SQL queries below for each of the following: List the names and cities of all customers List the different states the vendors come from (unique values only, no duplicates) Find the number of customers in California List product names and category descriptions for all products supplied by vendor Proformance List names of all employees who have sold to customer Rachel Patterson
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT