Question

In: Computer Science

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

Solutions

Expert Solution

a) Find the dno for the most expensive device

select dno from DEVICE where price=(select max(price) from DEVICE);

b) Find all providers that have the work fast in the name

select * from PROVIDER where pname like %work% or pname like %fast%;

c) Find the number of different device types (dtype)

select count(distinct dtype) from DEVICE;

d) Give all details of devices with price more than $400

select * from DEVICE where price>400;


Related Solutions

Write SQL queries for the following statements based on Employees table whose schema is given below:...
Write SQL queries for the following statements based on Employees table whose schema is given below: (Employee_ID,First_Name,Last_Name,Email,Phone_Number,Hire_Date,Job_ID,Salary, Manager_Id, Department_Id) a. Create the given table along with the following constraints: Phone_Number should not be left undefined, salary should be between 10000 and 20000, employee_id should uniquely identify rows and should not be left undefined. User-defined names should be given to constraints. b.  Display each employee’s last name, hire date and salary review date (which is the date after six months of service)....
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName,...
Write the following queries using the schema below Class (Number, Department, Term, Title) Student (Username, FirstName, LastName, Year) Takes (Username, Department, Number, Term, Grade) [clarification] In Student, Year is an integer. A student can be a 2nd year student. In that case, Year value would be 2. For the Takes relation: ·         Grade is NA for current semester students ·         Username is foreign key to Student ·         (Department, Number, Term) is foreign key to Class a)       Write an SQL query that returns the Term...
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
7. Using the provided schema of a Purchase Order Administration database, write the following queries in...
7. Using the provided schema of a Purchase Order Administration database, write the following queries in SQL. (In the schema, bold attributes are primary keys and italicized attributes are foreign keys.) SUPPLIER (SUPNR, SUPNAME, SUPADDRESS, SUPCITY, SUPSTATUS) SUPPLIES (SUPNR, PRODNR, PURCHASE_PRICE, DELIV_PERIOD) PRODUCT (PRODNR, PRODNAME, PRODTYPE, AVAILABLE_QUANTITY) PO_LINE (PONR, PRODNR, QUANTITY) PURCHASE_ORDER (PONR, PODATE, SUPNR) 7d) Write a nested SQL query to retrieve the supplier number, supplier name, and supplier status of each supplier who has a higher supplier status...
Write the following questions as queries in SQL. Use only the operators discussed in class (no...
Write the following questions as queries in SQL. Use only the operators discussed in class (no outer joins) Consider the following database schema: INGREDIENT(ingredient-id,name,price-ounce) RECIPE(recipe-id,name,country,time) USES(rid,iid,quantity) where INGREDIENT lists ingredient information (id, name, and the price per ounce); RECIPE lists recipe information (id, name, country of origin, and time it takes to cook it); and USES tells us which ingredients (and how much of each) a recipe uses. The primary key of each table is underlined; rid is a foreign...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2. 10. Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number...
Please use the books database pasted under question 4 to design the following SQL queries. Use...
Please use the books database pasted under question 4 to design the following SQL queries. Use any method such as subqueries, equi-join/inner-join, outer join, EXISTS 1. Find the name(s) of the publisher(s) who have published the computer book. 2. Find the name(s) of the author(s) that have authored more than one books. 3. Find the name(s) of the publisher(s) who published the least expensive book. 4. Find the name(s) of the author(s) who wrote the book with the greatest number...
Please use the books database pasted under question 4 to design the following SQL queries. Use...
Please use the books database pasted under question 4 to design the following SQL queries. Use any method such as subqueries, equi-join/inner-join, outer join, EXISTS 1. List the title_name and book type of the books that are published earlier than the earliest biography book 2. List the title_name and book type of the books published by 'Abatis Publishers' 3. Find the name(s) of the publisher(s) that have not published any book 4. Find the name(s) of the publisher(s) who have...
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least...
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least three rows in each table. For the On-Demand Streaming System, First, insert information for multiple users, at least three video items and insert the three different types of subscriptions (Basic, Advanced, Unlimited) into the database. Then insert at least three user subscriptions. Execute the queries and make sure they run correctly
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT