SELECT --43659, 43662 SalesOrderId, SalesOrderNumber, SubTotal, OrderDate, ( SELECT SUM(OrderQty) FROM Sales.SalesOrderDetail WHERE SalesOrderID not in (43659, 43661, 43662, 43668) ) AS TotalSales FROM Sales.SalesOrderHeader WHERE SalesOrderID not in (43659, 43661, 43662, 43668); The above query explained in this below video,