0% found this document useful (0 votes)
11 views2 pages

Lab 3 FD

Uploaded by

khoanv.23bi14223
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Lab 3 FD

Uploaded by

khoanv.23bi14223
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

SELECT *
FROM orders
WHERE order_date > '2006-03-24';

2.SELECT p.product_code, od.unit_price, od.quantity, (od.unit_price * od.quantity * (1 -


od.discount)) AS value_of_orders
FROM order_details AS od
INNER JOIN products AS p
ON p.id = od.product_id
WHERE od.order_id = 31;

3.SELECT o.id, o.order_date, c.company, (od.unit_price * od.quantity * (1 -


od.discount)) AS value
FROM orders AS o
INNER JOIN order_details AS od ON o.id = od.order_id
INNER JOIN customers AS c ON o.customer_id = c.id
WHERE o.order_date > '2006-03-24';

4.SELECT o.id, o.order_date, c.company, SUM((od.unit_price * od.quantity * (1 -


od.discount))) AS sub_total
FROM orders AS o
INNER JOIN order_details AS od ON o.id = od.order_id
INNER JOIN customers AS c ON o.customer_id = c.id
WHERE o.order_date > '2006-03-24'
GROUP
o.id;

5.SELECT o.id, o.order_date, c.company, SUM((od.unit_price * od.quantity * (1 -


od.discount))) AS sub_total
FROM orders AS o
INNER JOIN order_details AS od ON o.id = od.order_id
INNER JOIN customers AS c ON o.customer_id = c.id
WHERE o.order_date > '2006-03-24'
GROUP BY o.id
HAVING subtotal_value >= 800;

6.SELECT CONCAT(e.last_name,'', e.first_name) AS full_name, (od.unit_price *


od.quantity * (1-od.discount)) AS total_value
FROM employees AS e
INNER JOIN orders AS o ON o.employee_id = e.id
INNER JOIN order_details AS od ON od.order_id = o.id
WHERE (od.unit_price * od.quantity * (1-od.discount)) > 1000
ORDER BY (od.unit_price * od.quantity * (1-od.discount)) DESC;

7.

8.SELECT MIN(p.standard_cost), MAX(p.standard_cost), AVG(p.standard_cost),


STDDEV(p.standard_cost), VARIANCE(p.standard_cost)
FROM products AS p

9.SELECT p.category, AVG(p.list_price)


FROM products AS p
GROUP BY p.category;

10.SELECT MAX(o.shipping_fee), AVG(o.shipping_fee)


FROM orders AS o
INNER JOIN shippers AS s ON s.id = o.shipper_id
GROUP BY s.city;

11.

12.SELECT MIN(a.avger) FROM (SELECT p.category, AVG(p.list_price) AS avger


FROM products AS p GROUP BY p.category) AS a;

13.

14.
SELECT c.company, CONCAT(c.last_name,' ',c.first_name) AS full_name,
c.email_address, "C" AS type FROM customers as c UNION SELECT s.company,
CONCAT(s.last_name,' ',s.first_name) AS full_name, s.email_address, "S" AS type
FROM suppliers AS s;

15.

You might also like