troubleshooting Question

Group by using a join to produce sets of data

Avatar of soozh
soozhFlag for Sweden asked on
Microsoft SQL ServerSQL
2 Comments1 Solution55 ViewsLast Modified:
I have a table called #Data and i wish to summerise its contents. See the code below.

 
select 
  msr_Q1Total_Change,
  avg( cast( Has_Act_BasalaBehov as real ) ) as BasalaBehov,
  avg( cast( Has_Act_KognitivtStöd as real ) ) as KognitivtStöd
from #Data 
where msr_Q1Total_Change = 1
group by msr_Q1Total_Change

However i really need to produce the same summarisation for msr_Q1Total_Change  in the range 1 to 12.  So i am looking for 12 seperate results.

Is there a way to write this with a join that returns the values 1-12 ?  Thereby saving me a lot of cut and pasting and 12 seperate expressions.
ASKER CERTIFIED SOLUTION
OMC2000

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros