Step-by-step tutorial shows you how to use SQL subqueries in your SELECT statement & FROM and WHERE clauses!
Queries:
1) A subquery in the SELECT statement: SELECT customerid, freight, (SELECT AVG(freight) FROM orders) FROM orders
2) A subquery in the FROM clause: SELECT shipcountry, AVG(num_orders) FROM (SELECT customerid, shipcountry, count(*) AS num_orders FROM orders GROUP BY 1,2) sub GROUP BY 1
3) A subquery in the WHERE clause: SELECT * FROM orders WHERE employeeid IN (SELECT employeeid FROM employees WHERE LOWER(firstname) LIKE '%b%')
Get the Northwind Database: • How to Load a Sample P...
Support the Channel:
1) Subscribe: www.becomingad...
2) DataCamp:
3) Udacity:
Негізгі бет How to do Subqueries in SQL with Examples
No video
Пікірлер: 177