1USE AdventureWorks2016;
2GO
3SELECT Ord.SalesOrderID, Ord.OrderDate,
4 (SELECT MAX(OrdDet.UnitPrice)
5 FROM Sales.SalesOrderDetail AS OrdDet
6 WHERE Ord.SalesOrderID = OrdDet.SalesOrderID) AS MaxUnitPrice
7FROM Sales.SalesOrderHeader AS Ord;
8GO
1SUBQUERY IS NESTED QUERY INSIDE A SELECT,
2INSERT OR UPDATE METHODS. OR INSIDE ANOTHER SUBQUERY
3
1UPDATE Book SET note= 'editore: ' + (SELECT name FROM Publisher WHERE Publisher.ID = Book.publisher)
1UPDATE dataflair_emp1
2SET salary=35000
3WHERE emp_id = ( SELECT emp_id
4 FROM dataflair_emp1
5 WHERE post='Sr.Manager');
6select * from dataflair_emp1;
7
1SELECT column_name
2 FROM table_name1
3WHERE VALUE IN
4(SELECT column_name
5FROM table_name2
6WHERE condition)
7