Click here to Skip to main content
15,889,659 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I am trying to create a SSRS report for viewing the sales of 1 product in comparison to the sales of the rest of the products.

The table has 2 fields qty_supplied and qty_returned.
I can subtract qty_returned from qty_supplied to obtain qty_sold.

how can i get the sum of qty_supplied and sum of qty_returned for the products excluding the one selected?

Please help.

Thanks.
Ann
Posted
Comments
Herman<T>.Instance 23-Aug-11 10:14am    
please show the query you started with?
what makes a record unique identifiable?

1 solution

You can get the sum of all records where the product ID doesn't match the one in question.

It will be something like this:

SQL
@comparisonProductID

select 
     sum(p.qty_supplied)
   , sum(p.qty_returned)
from
   product_info_table p
where
   p.product ID <> @comparisonProductID


Cheers.
 
Share this answer
 
Comments
walterhevedeich 23-Aug-11 21:58pm    
Exactly. My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900