DRAG DROP
You have a database that includes the following tables:
You need to create a list of all customer IDs and the date of the last order that each customer placed. If the
customer has not placed any orders, you must return the date January 1, 1900. The column names must be
CustomerID and LastOrderDate.
Which four Transact-SQL segments should you use to develop the solution? To answer, move the appropriate
Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the
correct order.
Select and Place:
Explanation:
Box 1: SELECT..COALESCEā¦
The COALESCE function evaluates the arguments in order and returns the current value of the first expression
that initially does not evaluate to NULL.
Box 2: ..LEFT OUTER JOIN..
The LEFT JOIN (LEFT OUTER JOIN) keyword returns all rows from the left table (table1), with the matching
rows in the right table (table2). The result is NULL in the right side when there is no match. A customer might
have no orders so the right table must be allowed have a NULL value.
Box 3: ON c.custid = o.custid
We JOIN on the custID column, which is available in both tables.
Box 4: GROUP BY c.custidhttps://technet.microsoft.com/en-us/library/ms189499(v=sql.110).aspx
http://www.w3schools.com/sql/sql_join_left.asp
correct