1. For each query, there are one or more things to do. Some of these queries use SQL constructs we haven't covered in class but that you should be able to figure out the meaning of.
a.
SELECT C.custid, C.companyname
FROM Sales.Customers AS C
LEFT OUTER JOIN Sales.Orders as O
ON C.custid = O.custid
WHERE O.orderid IS NULL
Provide the result set generated by this query.
One of the result rows should be (22, Customer DTDMN). What does this tell you about customer 22?
b.
SELECT custid, companyname
FROM Sales.Customers as C
WHERE NOT EXISTS (
SELECT * FROM Sales.Orders as O
WHERE O.custid = C.custid
)
Explain what the result set represents.
c.
SELECT empid
FROM HR.Employees as E
WHERE (
SELECT COUNT(*)
FROM Sales.Orders as O
WHERE O.empid = E.empid
) > 90
Explain what the result set represents.
Write a query that produces the same result that uses GROUP BY and HAVING.
a.) Left outer join basically returns everything from Customer table irrespective of the fact that wether the Orders table has related value, hence there are various null value in the resultant table.
According to query we have to return customer id and company name from the resultant table after performing left outer join.
Hence, (22, Customer DTDMN) means customer with customer id=22 has not placed any order with the company Customer DTDMN.
b.) It will give wrong answer as the inner loop will select everything from orders table and then the outer loop would not be able to exclude the instances on the basis of particular values.
C.) It has 2 loops inner loop and outer loop the value obtained from outer loop dependent on value of inner loop.
Inner loop: it will perform natural join of orders and employee table on the basis of employeId amd return the count
Outer loop: it will return all empId where the count is greator than 90.
1. For each query, there are one or more things to do. Some of these queries...
QUERY EXAMPLE2 SELECTfrom Employee em (Refer to query example 2 to answer questions 12- 13) 12. You plan to join the Location table and fear there may be some employees with no location. You want to make sure that the query returns a list of all employee What join clause would you add to the query above? records. A. LEFT JOIN Location lo ON em.LocationlD lo LocationID B. RIGHT JOIN Location lo ON em.LocationID lo.LocationlD C. INNER JOIN Location lo...
A(n) __________________ is a logical connection between rows in two tables where data in one table references data in another table. The SQL ________________ statement removes a table from a database. The relational algebra "restrict" operator selects only the rows from the input table(s) that satisfy a condition expressed in the _________________ clause. The SQL/PL ______________ command is used to re-direct the output of a script file to a text file. The ________________________ join creates a result set that includes the...
can someone solve these quick
please and thank you!
sql chapter 4
Query #1: List the company name, contact name, contact title and
the phone number for customers who HAVE NOT put in an order. Use an
outer join.
Query #2: Create a listing displaying the employee first name,
last name and the full name (First name space Last Name) of the
person they report to (Supervisor). This is a self-join. If an
employee does not report to anyone then...
QUESTION 21 Complete the table below by matching each definition with the appropriate SQL clause. -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A mandatory clause that is at the start of all SQL retrieval queries -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause used to return only the values in a result table that are unique -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause used to filter tuples according to some condition or predicate, like selection in relational algebra -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause that is used to list the tables and any joins required in a query...
Please help me to solve Please, No handwriting COURSE; introduction to database Q- write a query SQL by Using the info below A. Normalize the Tables (in 3NF at least) B. Create the Normalized Tables and Populate them with at least 5 Rows C. Write the Wholesale Management System requested Queries & Execute them VERY IMPORTANT Screenshots from MySQL (or any other software you use) of all the tables after queries result. - Database system for a Wholesale Management System...
QUESTION 5 Suppose there are two tables: A and B. and we run command SELECT * from A LEFT JOIN B on A.orderid = B.orderid. What would be the code output? only the records from table A where tables A and B have the same orderid only the records from table B where tables A and B have the same orderid the complete set of records from table A, along with the matching records (depending on the availability) from table...
You will develop an E-Commerce database used to maintain
customers, products and sales information. You are required to 1)
gather and analyze requirements 2) design logical structure of the
database 3) create stored procedures to develop the tables and
insert the data 4) write SQL statements for data extraction and
reporting.
Throughout the course of this semester you have analyzed the
requirements for an eCommerce database, designed and developed your
database. As a class we have gone through the process...
Kindly assist in the solution to these problems. 2a) Give an example of when a view might be helpful. Give an example of when a view might be required for purposes of confidentiality and security. b) In an explicit LEFT JOIN, the first table mentioned after the FROM keyword should be the table whose rows you want to include in the results even if the other table does not have a corresponding value for the field that’s being joined on....
What happens when you try to compile and run the following code? String query = "INSERT INTO Invoices (InvoiceDate InvoiceTotal) " + "VALUES ('2/10/01', '443.55')"; Statement statement = connection.createStatement(); statement.executeUpdate(query); a. A SQLException is thrown at runtime because the executeUpdate method can’t accept a String object. b. A SQLException is thrown at runtime because the SQL statement is coded incorrectly. c. An error occurs at compile time because the SQL statement is coded incorrectly. d. This code compiles and...
Create the database and tables
for the database. Show all SQL statements. Include primary and
foreign keys. Insert data into each table. Show select statements
and display the output of each table. Note:Student’s name must be
inserted into table as part of the data! Perform the SQL below:
Query one table and use WHERE to filter the results. The SELECT
clause should have a column list, not an asterisk (*). State the
purpose of the query; show the query and...