SQLTeam.com | Weblogs | Forums

Round to 2 decimal places


I need help rounding the 'Percent Scrapped' to 2 decimal places.

p.Name AS 'Product Name',
SUM(wo.ScrappedQty) AS 'Scrapped Qty',
SUM(wo.OrderQty) AS 'Order Qty',
CONVERT(varchar, 100 * SUM(CONVERT(float,wo.ScrappedQty))/SUM(CONVERT(float,wo.OrderQty))) + '%' AS 'Percent Scrapped'
FROM Production.WorkOrder AS wo
JOIN Production.Product AS p ON wo.ProductID = p.ProductID
WHERE YEAR(wo.StartDate) = 2014
GROUP BY wo.ProductID, p.Name
HAVING SUM(wo.OrderQty) > 50
ORDER BY 'Percent Scrapped' DESC


try the ROUND function