Knowee
Questions
Features
Study Tools

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';

Question

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';

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

Solution

The correct queries that would generate the required report are:

a. SELECT c.cust_last_name,p.prod_name,s.quantity_sold FROM products p JOIN sales s ON(p.prod_id=s.prod_id) JOIN customers c ON(s.cust_id=c.cust_id) WHERE c.cust_city='Tokyo';

c. SELECT c.cust_last_name,p.prod_name,s.quantity_sold FROM sales s JOIN products p USING (prod_id) JOIN customers c USING (cust_id) WHERE c.cust_city='Tokyo';

The first query (a) uses the traditional JOIN syntax where the joining condition is specified in the ON clause. It first joins the products and sales tables on the prod_id, and then joins the result with the customers table on the cust_id. The WHERE clause then filters for customers in 'Tokyo'.

The third query (c) uses the USING keyword to specify the columns to join on. This is a feature of SQL that can be used when the columns to join on have the same name in both tables. It first joins the sales and products tables on the prod_id, and then joins the result with the customers table on the cust_id. The WHERE clause then filters for customers in 'Tokyo'.

This problem has been solved

Similar Questions

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.

Consider the below table:Products TableColumn NameDatatypeConstraintProd_idNumberPKProd_nameVarchar Prod_list_pricevarchar Cust_credit_limitNumber  What would be the outcome of executing the below SQL statement?select prod_name from products where prod_id in(select prod_id from products where prod_list_price=(select max(prod_list_price) from products where prod_list_price<(select max(prod_list_price)from products)));Select one:a.It shows the names of all products in the table.b.It shown the names of products whose list price is the second highest in the tablec.It produces an errord.It shown the names of all products whose list price is less than the maximum list priceClear my choiceQuestion 9Not yet answeredMarked out of 1.00Flag questionTipsQuestion text_____ is used to retrieve records that do not meet the join conditionSelect one:a.Outer Joinb.Equi Joinc.Non Equi Joind.Self Join

Table below shows the structure of a table named Car. Use it to answer the questions that follow:FieldData TypeCarIDIntegerModelVarChar(20)YearofManufactureDateStatusInteger      Write an SQL statement that would perform each of the following:                    i.            Create the table Car with the relevant fields;                                           (3 Marks)                  ii.            Make CarID the primary Key;                                                                  (2 Marks)                iii.            Add fields name Make and Price that store 30 characters and numbers respectively.                                                                                                                      (3 Marks

The PART table contains these columns:ID NUMBER(7) PKCOST NUMBER(7,2)PRODUCT_ID NUMBER(7)Evaluate these two SQL statements:1.SELECT ROUND(MAX(cost),2),ROUND(MIN(cost),2),ROUND(SUM(cost),2),ROUND(AVG(cost),2)FROM part;2.SELECT product_id, ROUND(MAX(cost),2),ROUND(MIN(cost),2),ROUND(SUM(cost),2),ROUND(AVG(cost),2)FROM partGROUP BY product_id;How will the results differ?Select one:a.One of the statements will generate an error.b.The results will be the same, but the display will differ.c.Statement 1 will only display one row of results; statement 2 could display more than one.d.Statement 1 will display a result for each part; statement 2 will display a result for each product.

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'?

1/2

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.