calculations

statements
#tsql#statements

This example returns only the rows for

that have a product line of

and that have

days to manufacture that’s less than.

The following examples return all rows from the

table. The first example returns total

sales and the discounts for each product. In the second example, the total revenue is calculated

for each product.

This query calculates the revenue for each product in each sales order.

Product

R
4

Product

FROM
Production.Product
ORDER
BY
Name
ASC
;
GO
USE
AdventureWorks2025;
GO
SELECT
Name
,
ProductNumber,
ListPrice
AS
Price
FROM
Production.Product
WHERE
ProductLine =
'R'
AND
DaysToManufacture < 4
ORDER
BY
Name
ASC
;
GO
USE
AdventureWorks2025;
GO
SELECT p.Name
AS
ProductName,
NonDiscountSales = (OrderQty * UnitPrice),
Discounts = ((OrderQty * UnitPrice) * UnitPriceDiscount)
FROM
Production.Product
AS p
INNER
JOIN
Sales.SalesOrderDetail
AS sod
ON p.ProductID = sod.ProductID
ORDER
BY
ProductName
DESC
;
GO