subquery in select statement sql server code example
Example 1: mssql subqueries
USE AdventureWorks2016;
GO
SELECT Ord.SalesOrderID, Ord.OrderDate,
(SELECT MAX(OrdDet.UnitPrice)
FROM Sales.SalesOrderDetail AS OrdDet
WHERE Ord.SalesOrderID = OrdDet.SalesOrderID) AS MaxUnitPrice
FROM Sales.SalesOrderHeader AS Ord;
GO
Example 2: subquery sql
UPDATE Book SET note= 'editore: ' + (SELECT name FROM Publisher WHERE Publisher.ID = Book.publisher)
Example 3: subquery in sql
SUBQUERY IS NESTED QUERY INSIDE A
SELECT, INSERT OR UPDATE METHODS.
OR INSIDE ANOTHER SUBQUERY