Question : SSRS percentage equation

I am trying to divide number of quotes won (W) by Total # of quotes.


This isn't bringing back any returns:
Count(QUOTE.STATUS  'W') / Sum(QUOTE.STATUS) as %Won

Thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
SELECT     
	QUOTE.ENTITY_ID, 
	QUOTE.QUOTE_DATE, 
	QUOTE.EXPIRATION_DATE, 
	QUOTE.WON_LOSS_DATE, 
	CASE (QUOTE.STATUS) WHEN 'W' THEN 'Won' WHEN 'P' THEN 'Printed' WHEN 'A' THEN 'InHouse' END AS Status, 
	QUOTE.ID, 
	QUOTE.NAME, 
	QUOTE.SALESREP_ID,     
	QUOTE.WON_LOSS_REASON, 
	QUOTE_PRICE.QUOTE_ID, 
	QUOTE_PRICE.QTY, 
	QUOTE_PRICE.UNIT_PRICE, 
	QUOTE_LINE.PRODUCT_CODE,                       
	QUOTE_LINE.PART_ID, 
	YEAR(QUOTE.QUOTE_DATE) AS Year, 
	MONTH(QUOTE.QUOTE_DATE) AS Month, 
	PART.USER_8, QUOTE_LINE.LINE_NO,                       
	QUOTE_LINE.CUSTOMER_PART_ID, 
	COALESCE (QUOTE_LINE.PART_ID, QUOTE_LINE.CUSTOMER_PART_ID, QUOTE_LINE.DESCRIPTION) AS ISNullPartID, 
	QUOTE_LINE.DESCRIPTION, 
	QUOTE_PRICE.QTY * QUOTE_PRICE.UNIT_PRICE AS NetPrice, 
	CASE WHEN isnull(PART.USER_8, '') = '' THEN 'WORK ORDER PN' ELSE PART.USER_8 END AS User_8PartType
FROM         QUOTE_PRICE INNER JOIN
                      QUOTE_LINE ON QUOTE_PRICE.QUOTE_ID = QUOTE_LINE.QUOTE_ID AND QUOTE_PRICE.QUOTE_LINE_NO = QUOTE_LINE.LINE_NO INNER JOIN
                      QUOTE ON QUOTE_LINE.QUOTE_ID = QUOTE.ID LEFT OUTER JOIN
                      PART ON QUOTE_LINE.PART_ID = PART.ID
WHERE     (YEAR(QUOTE.QUOTE_DATE) IN (@Year)) AND (MONTH(QUOTE.QUOTE_DATE) IN (@Month))
ORDER BY QUOTE_PRICE.QUOTE_ID

Answer : SSRS percentage equation

The problem is that your existing query doesn't summarize - it's detail.  You can't mix this easily, and where would you even display it in the query output.  However, assuming you simply want the output to use the same dataset as is returned by your query, you can generate it either by rewriting the query as a Summary-form query, or using the output of the existing query as the input to this query.  I'm going to reformat the query to use the QUOTE table you reference:




1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
SELECT 
    Cast('Won' as Char(10)) + Right(Space(9) +
    CAST(
        CAST(
            SUM(CASE WHEN Quote.Status = 'W' THEN 1 ELSE 0 END) / Cast(COUNT(Quote.ENTITY_ID) as decimal(8,4)
                ) * 100 as Decimal(8,2)
            ) As Varchar(8))
         , 9) + '%'
        FROM QUOTE
UNION
SELECT 
    Cast('Printed' as Char(10)) + Right(Space(9) +
    CAST(
        CAST(
            SUM(CASE WHEN Quote.Status = 'P' THEN 1 ELSE 0 END) / Cast(COUNT(Quote.ENTITY_ID) as decimal(8,4)
                ) * 100 as Decimal(8,2)
            ) As Varchar(8))
         , 9) + '%'
        FROM QUOTE
UNION
SELECT 
    Cast('Lost' as Char(10)) + Right(Space(9) +
    CAST(
        CAST(
            SUM(CASE WHEN Quote.Status = 'A' THEN 1 ELSE 0 END) / Cast(COUNT(Quote.ENTITY_ID) as decimal(8,4)
                ) * 100 as Decimal(8,2)
            ) As Varchar(8))
         , 9) + '%'
FROM QUOTE
WHERE YEAR(QUOTE.QUOTE_DATE) = @YEAR 
    AND MONTH(QUOTE.QUOTE_DATE) = @Month
Random Solutions  
 
programming4us programming4us