|
Hi, I have a scenario that need to calculate amount ..,I have one table SalesAmount. I have to calculate the amount for a given saleid ,if the type is either "Retail" or "WholeSale" but not both for same saleid . Can any one help me how to write a query to check all these
(comments are locked)
|
|
select saleid, type , case count(type) when count(type) >=2 sum(amnt)/count(type) else 0 from table group by saleid,type thanks kannan for ur replay but need some more enhancements , For Ex:In some cases saleid having 1 record with either retail or wholesale need to get that amount value. and 3 records with 2 of Retail and 1 wholesale i have to get 0 as amount(mixed scenario) but your query won`t works in that case.
Sep 24 '12 at 11:34 AM
ANJI
(comments are locked)
|

