sqlh12.2

-- Opdracht 1

/* Vertaal de onderstaande SQL instructie naar een SQL instructie zonder subquery. */

SELECT cust_name
FROM Customers
WHERE cust_id IN (	SELECT cust_id
					FROM Orders
					WHERE order_num IN (	SELECT order_num
											FROM OrderItems
											WHERE prod_id = 'BR02'));
											
SELECT 
											
-- Opdracht 2

/* Vertaal de onderstaande SQL instructie naar een SQL instructie zonder subquery. */

SELECT cust_name 
FROM Customers
WHERE cust_id IN (	SELECT cust_id
					FROM Orders
     				WHERE NOT DATEPART (MM,order_date) = 1);

SELECT 
											
-- Opdracht 3

/* Vertaal de onderstaande SQL instructie naar een SQL instructie zonder subquery. */

SELECT 	cust_name, 
		cust_state,
		(	SELECT COUNT(*)
			FROM Orders
			WHERE Orders.cust_id = Customers.cust_id) as orders 
FROM Customers
ORDER BY cust_name;

SELECT

-- Opdracht 4

/* Vertaal de onderstaande SQL instructie naar een SQL instructie zonder subquery. */

SELECT prod_name 
FROM Products
WHERE prod_price IN (	SELECT MAX (prod_price) 			
						FROM Products);

SELECT




Download hier het bestand.