SQLTeam.com | Weblogs | Forums

Round to 2 decimal places


#1

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

SELECT TOP 10
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


#2

try the ROUND function