Skip to main content
nikos101
Inspiring
November 18, 2008
Question

What is the best way to Aggregate query results

  • November 18, 2008
  • 13 replies
  • 1482 views
What is the best way to Aggregate query results that are retrived in a ms sql while statement,into a single query result?
This topic has been closed for replies.

13 replies

Inspiring
November 18, 2008
> I may have to use a temparay table

... or a table variable. What is your loop doing? Is it possible to write the query without a loop?
nikos101
nikos101Author
Inspiring
November 18, 2008
Yes I am doing that but its returning seperate queries,

declare @month int
set @month = 0
while (@month <12)

BEGIN
select stuff


SET @month=@month + 1
end

I may have to use a temparay table
Participating Frequently
November 18, 2008
Use the database aggregate functions so your query only returns one row.