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)