Knowee
Questions
Features
Study Tools

Consider the below tables:Promotions TableColumn NameDatatypeConstraintPromo_idNumberPKPromo_nameVarchar Promo_begin_dateDate Promo_end_dateDate  Sales TableColumn NameDatatypeConstraintPromo_idNumberFKCust_idNumberFKTime_idDate  Customer TableColumn NameDatatypeConstraintcust_idNumberPKcust_nameVarchar The Below query will generate a report showing the promo name along with the customer name for all products that were sold during their promo campaign and before 30th October 2007.SELECT promo_name,cust_name FROM promotions p JOIN sales s ON(time_id BETWEEN promo_begin_date AND promo_end_date) JOIN customer c ON (s.cust_id = c.cust_id) AND time_id < '30-oct-2007'; Which statement is true regarding the above query? Select one:a.It produces an error because the join order of the tables is incorrect.b.It produces an error because equijoin and nonequijoin conditions cannot be used in the samec.It executes successfully but does not give the required result.d.It executes successfully and gives the required result.

Question

Consider the below tables:Promotions TableColumn NameDatatypeConstraintPromo_idNumberPKPromo_nameVarchar Promo_begin_dateDate Promo_end_dateDate  Sales TableColumn NameDatatypeConstraintPromo_idNumberFKCust_idNumberFKTime_idDate  Customer TableColumn NameDatatypeConstraintcust_idNumberPKcust_nameVarchar The Below query will generate a report showing the promo name along with the customer name for all products that were sold during their promo campaign and before 30th October 2007.SELECT promo_name,cust_name FROM promotions p JOIN sales s ON(time_id BETWEEN promo_begin_date AND promo_end_date) JOIN customer c ON (s.cust_id = c.cust_id) AND time_id < '30-oct-2007'; Which statement is true regarding the above query? Select one:a.It produces an error because the join order of the tables is incorrect.b.It produces an error because equijoin and nonequijoin conditions cannot be used in the samec.It executes successfully but does not give the required result.d.It executes successfully and gives the required result.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

c. It executes successfully but does not give the required result.

The reason is that the join condition for the sales and promotions tables is incorrect. The query is trying to join on the condition that the 'time_id' is between 'promo_begin_date' and 'promo_end_date'. However, 'time_id' and 'promo_begin_date'/'promo_end_date' are not related in a way that would allow for a proper join.

The correct join condition would be 's.promo_id = p.promo_id', assuming that 'promo_id' in the sales table is a foreign key referencing 'promo_id' in the promotions table.

The condition 'time_id' < '30-oct-2007' can be included in the WHERE clause to filter the results to only include sales that occurred before October 30, 2007.

This problem has been solved

Similar Questions

Consider the following table:Product TableColumn NameDataTypeConstraintprod_nameVarchar2(20) prod_idNumber(10)PK Customer TableColumn NameDataTypeConstraintcust_last_nameVarchar2(20) cust_idNumber(10)PKcust_cityVarchar2(20)  Sales TableColumn NameDataTypeConstraintprod_idNumber(10)FKcust_idNumber(10)FKquantity_soldNumber(10,2)  Generate a report that gives details of the customer's last name, name of the product and the quantity sold for all customers in 'Tokyo'.Which two queries give the required result? (Choose two.)Select one or more:a.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM products p JOIN sales sON(p.prod_id=s.prod_id)JOIN customers cON(s.cust_id=c.cust_id)WHERE c.cust_city='Tokyo';b.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM products p JOIN sales s JOIN customers cON(p.prod_id=s.prod_id)ON(s.cust_id=c.cust_id)WHERE c.cust_city='Tokyo';c.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM sales s JOIN products pUSING (prod_id)JOIN customers cUSING (cust_id)WHERE c.cust_city='Tokyo';d.SELECT c.cust_last_name,p.prod_name,s.quantity_soldFROM products p JOIN sales sUSING (prod_id)ON(p.prod_id=s.prod_id)JOIN customers cUSING(cust_id)WHERE c.cust_city='Tokyo';

Consider the following table structure:Productidnamepricetype_idProduct_typeidnamediscountWhich of the following query is used to display the product_type name, product name and discount of product_type named 'Books'?

Description : Given three tables: salesperson, company, orders.Output all the names in the table salesperson, who didn’t have sales to company 'RED'.ExampleInputTable: salespersonsales_idnamesalarycommission_ratehire_date1John10000064/1/20062Amy12000055/1/20103Mark650001212/25/20084Pam25000251/1/20055Alex50000102/3/2007The table salesperson holds the salesperson information. Every salesperson has a sales_id and a name.Table: companycom_idnamecity1REDBoston2ORANGENew York3YELLOWBoston4GREENAustinThe table company holds the company information. Every company has a com_id and a name.Table: ordersorder_idorder_datecom_idsales_idamount11/1/20143410000022/1/201445500033/1/2014115000044/1/20141425000The table orders holds the sales record information, salesperson and customer company are represented by sales_id and com_id.OutputnameAmyMarkAlexExplanationAccording to order '3' and '4' in table orders, it is easy to tell only salesperson 'John' and 'Alex' have sales to company 'RED', so we need to output all the other names in table salesperson.Optionsselect s.namewhere s.sales_id not in( select sales_id from orders as o left join company as con o.com_id = c.com_id where c.name = 'RED');select s.namefrom salesperson as swhere s.sales_id not in( select sales_id from orders as o left con o.com_id = c.com_id where c.name = 'RED');select s.namewhere s.sales_id not in( select sales_id from orders as o left join company as con o.com_id where c.name = 'RED');select s.namefrom salesperson as swhere s.sales_id not in( select sales_id from orders as o left join company as con o.com_id = c.com_id where c.name = 'RED');

You are a developer for a Microsoft SQL Server database instance used to support a customer service application. You create tables named complaint, customer, and product as follows:CREATE TABLE [dbo].[complaint] ([ComplaintID] [int], [ProductID] [int], [CustomerID] [int], [ComplaintDate] [datetime]);CREATE TABLE [dbo].[customer] ([CustomerID] [int], [CustomerName] [varchar](100), , , , );CREATE TABLE [dbo].[product] ([ProductID] [int], [ProductName] [varchar](100), [SalePrice] [money], [ManufacturerName] [varchar](100));You need to write a query to identify all customers who have complained about products that have an average sales price of 500 or more from September 01, 2011.Which SQL query should you use?SELECT c.CustomerName, AVG(p.SalePrice) AS Sales FROM product p INNER JOIN complaint com ON p.ProductID = com.ProductID INNER JOIN customer c ON com.CustomerID = c.CustomerID WHERE com.ComplaintDate > '09/01/2011' GROUP BY c.CustomerName HAVING AVG(p.SalePrice) >= 500;SELECT c.CustomerName, SUM(p.SalePrice) AS Sales FROM product p INNER JOIN complaint com ON p.ProductID = com.ProductID INNER JOIN customer c ON com.CustomerID = c.CustomerID WHERE com.ComplaintDate > '09/01/2011' AND SUM(p.SalePrice) >= 500 GROUP BY c.CustomerName;SELECT c.CustomerName, AVG(p.SalePrice) AS Sales FROM product p INNER JOIN complaint com ON p.ProductID = com.ProductID INNER JOIN customer c ON com.CustomerID = c.CustomerID WHERE com.ComplaintDate > '09/01/2011' AND AVG(p.SalePrice) >= 500 GROUP BY c.CustomerName;None of the above

Write a query to retrieve the names of customers who have made multiple purchases and the count of their purchases.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.