Link to home
Start Free TrialLog in
Avatar of tcmmaxt
tcmmaxtFlag for United States of America

asked on

How i return the sum of a range numeric column count values isql 2005 server

Expert: I need to return the Sum of cnt (totals of all counts) in the SP procedure below with along with the other data back to my dot net app. Could someone kindly show me what changes I have to make to my SP  to return the Sum ?  thanks for your help here.  

ALTER procedure [dbo].[GetRatingCount]
   @startdate datetime,
   @enddate datetime
as
ALTER procedure [dbo].[GetRatingCount]
   @startdate datetime,
   @enddate datetime
as
set nocount on
select rating_type, count(*) cnt
from TableA
where Date1 >= @startdate
and  Date1 < @enddate
group by rating_type
Avatar of bprojoe
bprojoe

you can return a second table from your Sp.  Just add another select.
select count(*) as cnt
from TableA
where Date1 >= @startdate
and  Date1 < @enddate

Or you can do a union and add one more row to your table
select rating_type, count(*) cnt
from TableA
where Date1 >= @startdate
and  Date1 < @enddate
group by rating_type
Union
select count(*) as cnt
from TableA
where Date1 >= @startdate
and  Date1 < @enddate
ASKER CERTIFIED SOLUTION
Avatar of bprojoe
bprojoe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tcmmaxt

ASKER

nice