Question

write the select statement with correlated query to accomplish the following: list the restaurants(restaurantid) whose annual...

write the select statement with correlated query to accomplish the following:

list the restaurants(restaurantid) whose annual sales(annualsales) is lower than the average sales of restaurants in its own type(typeofservice)

Homework Answers

Answer #1

Correlated SQL query:

SELECT restaurantid FROM restaurants WHERE annualsales < ( SELECT AVG(annualsales) FROM restaurants GROUP BY typeofservice )

explanation :

  • In correlated queries inner query executes once per each row of the outer query.
  • In internal query restaurants are grouped by type of service . Average of the annualsales is calculated of all the restaurants from this group .
  • For each value of annualsales from outer query checks with the output of inner query i.e., whether the annual sales of restaurant is less than average sale or not.
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
A(n) _____ is a query that is embedded (or nested) inside another query. Select one: a....
A(n) _____ is a query that is embedded (or nested) inside another query. Select one: a. operator b. subquery c. alias d. view If a subquery returns list of values, which operator can be used in the outer query predicate? Select one: a. > b. < c. IN d. = Which query returns a list of all products with a price greater than or equal to the average product price? Select one: a. SELECT P_CODE,MAX(AVG(P_PRICE)) FROM PRODUCT GROUP BY P_CODE;...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year,...
Write a SQL statement for the following query: Relational Schema: Part( P #, PName, Producer, Year, Price) (P# is the primary key) Customer( C#, CName, City) (C# is the primary key) Supply(S#, P#, C#, Quantity, Amount, Date) (S# is the primary key) Query: For each Apple product supplied to more than 10 different customers in Chicago in 2020, list product number, product name, total supply quantity, and total supply amount. Sort the result by product name.
Write SELECT statement that returns the "Representative ID" and their highest sales total of that sales...
Write SELECT statement that returns the "Representative ID" and their highest sales total of that sales representative, grouped by the " Representative ID" . Representative ID    : rep_id column of rep_totals table "Highest sales of Representative " : maximum sales_total of that representative. Return only the rep_id whose highest sales_total is greater than 900000 Expected Output: Representative ID Highest sales of representative 1 1274856.38 2 978465.99 3 1132744.56
implement in Oracle Sql please 5) Write a SELECT statement that answers this question: Which products...
implement in Oracle Sql please 5) Write a SELECT statement that answers this question: Which products have a list price that’s greater than the average list price for all products? Return the product_name and list_price columns for each product. Sort the results by the list_price column in descending sequence.
Given the following two related tables, write the SQL SELECT statement to solve the following queries...
Given the following two related tables, write the SQL SELECT statement to solve the following queries about developers (Dev) and programs (Prog). The id column in Dev and Prog is the relation between the two tables. Dev(id, name, dept, salary) Prog(id, title, language, lines, size); 1. List name of Devs who have written more than 1000 line programs 2. List title of all programs written in C++ language 3. List name of all developers who have written C++ programs
Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name"...
Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name" column with the rep_first_name column , a comma, a space and the rep_last name. Return only the sales representatives whose last name starts with "Mar" Write a SELECT statement that joins the sales_rep table to the sales_totals table using JOIN clause and returns these columns : "Representative Last name" : rep_last_name from sales_rep table " Year of sales " : sales_year column of sales_totals...
You query data from emp2 table with below SQL statement: SQL> SELECT *     FROM  emp2; NAME SSN...
You query data from emp2 table with below SQL statement: SQL> SELECT *     FROM  emp2; NAME SSN ------------- ------------------------ Joe 452852452 Mary 444525962 Fred 445212525 Tom 492525252 Lucy   172826152   Now, you query data from emp2 table with below SQL statement again: SQL> SELECT AVG(LENGTH(name)) AS column1, SUM(INSTR(ssn, '%@',2,2)) AS column2 FROM  emp2 WHERE name = INICAP(name); What will be displayed for the output of column1 and column2? A. The value in column1 will be 3.5 and the value in column2 will be...
1.Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name"...
1.Write a SELECT statement that returns "Representative full name" from sales_rep table. Format "Representative full name" column with the rep_first_name column , a comma, a space and the rep_last name. Return only the sales representatives whose last name starts with "Mar" 2. Write a SELECT statement that  joins the sales_rep table to the sales_totals table using JOIN clause and returns these columns : "Representative Last name" : rep_last_name from sales_rep table " Year of sales " : sales_year column of sales_totals...
java Write a single Java statements to accomplish each of the following: a) Displaythevalueoftheseventhelementofcharacterarraych. b) Considering...
java Write a single Java statements to accomplish each of the following: a) Displaythevalueoftheseventhelementofcharacterarraych. b) Considering “Scanner in = new Scanner (System.in);”, input a value into element 5 of one-dimensional double array nums. c) Initialize each of the four elements of the one-dimensional integer array test to 7. d) Declare and create an array called table as a float array that has four rows and three columns. e) Considering the following ArrayList declaration, insert “test” at the fourth position (index...
1, The following query is called_________ SQL>select e.empno,e.ename, m.ename, m.empno from emp e, emp m where...
1, The following query is called_________ SQL>select e.empno,e.ename, m.ename, m.empno from emp e, emp m where e.mgr = m.empno; cross join outer join Self join Full join Natural Joins 2. Steve wants to write a query to display the employee last name, department name, location id, and city of all employees who earn a commission. He wrote the following query. is it true or false. SELECT e.last_name, d.department_name, d.location_id, l.city FROM employees e, departments d, locations l WHERE e.department_id =...