A) FIND A CUSTOMER WHO HAVE NOT PLACED ANY ORDERS(COMPLETE THE QUERY) Write a qu
ID: 3824911 • Letter: A
Question
A) FIND A CUSTOMER WHO HAVE NOT PLACED ANY ORDERS(COMPLETE THE QUERY)
Write a query to display order number, customer number, order date and items ordered for some customer and Make Sure provide the result output:
Write a query to display each item ordered for order #1, its standard price, and total price for each item ordered and Make sure provide the result output.
Write your own query to display some data – Make sure describe what you are trying to display and write your query with the result.
Explanation / Answer
===========================================================================
A) FIND A CUSTOMER WHO HAVE NOT PLACED ANY ORDERS(COMPLETE THE QUERY)
----------------
ANSWER:
----------------
SELECT
CustomerID
FROM
Customer_T
WHERE
CustomerID
NOT IN
(SELECT CustomerID FROM Order_T);
------------------------
EXPLANATION:
------------------------
First query the customer ids which made some order, and remove the ids as sub query to get the
customers not placed order.
===========================================================================
Write a query to display order number, customer number, order date and items ordered for some customer and Make Sure provide the result output:
----------------
ANSWER:
----------------
SELECT
ORDER.OrderID,
ORDER.CustomerID,
ORDER.ORDERDATE,
ORDER.OrderedQuantity
FROM
Order_T ORDER
WHERE
ORDER.CustomerID = 100;
-------------------------
EXPLANATION:
-------------------------
Perform select query order table.
===========================================================================
Write a query to display each item ordered for order #1, its standard price, and total price for each item ordered and Make sure provide the result output.
----------------
ANSWER:
----------------
SELECT
ORDERLINE.ProductID,
PRODUCT.ProductStandardPrice,
Sum(ORDERLINE.OrderedQuantity * PRODUCT.ProductStandardPrice) As 'TOTAL PRICE'
FROM
Product_T PRODUCT
INNER JOIN
OrderLine_T ORDERLINE ON PRODUCT.ProductID = ORDERLINE.ProductID
GROUP BY
ORDERLINE.ProductID, PRODUCT.ProductStandardPrice, ORDERLINE.OrderID
HAVING
ORDERLINE.OrderID = 1;
------------------------
EXPLANATION:
------------------------
Perform inner join on ORDERLINE and PRODUCT table to get price and calclate it and apply where class.
===========================================================================
Write your own query to display some data – Make sure describe what you are trying to display and write your query with the result.
---------------
ANSWER:
---------------
This query will fetch all the order info where ORDER data is given date.
SELECT
ORDER.OrderID,
ORDER.CustomerID,
ORDER.ORDERDATE,
ORDER.OrderedQuantity
FROM
Order_T ORDER
WHERE
ORDER.ORDERDATE = "2017-04-24";
------------------------
EXPLANATION:
------------------------
Perform select query order table with given date.
===========================================================================
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.