Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Re-Arrange Columns?

$
0
0

I have a query that gives me the data that I want. I am being asked to present it is a certain format and I just can't find how to do it. I hope I am in the correct forum to start. I will post my sql below, and then two screen shots. The first is what I get from my query and the second is the requested format. I am wondering if there is a way to write the query so that the requested format is satisfied. A report will be made that will show updated data.

Thanks.

wdg

SELECT COUNT((CASE WHEN dbo.ufn_GETAGE(Birthdate, GETDATE()) BETWEEN 4 AND 10 THEN Birthdate END)) AS [10 & Under], COUNT((CASE WHEN dbo.ufn_GETAGE(Birthdate, GETDATE()) BETWEEN 11 AND 
                  14 THEN Birthdate END)) AS [11 - 14 years of age], COUNT((CASE WHEN dbo.ufn_GETAGE(Birthdate, GETDATE()) BETWEEN 15 AND 18 THEN Birthdate END)) AS [15 - 18 years of age], Individuals.Ethnicity, 
                  Individuals.Gender
FROM     Individuals INNER JOIN
                  EnrollmentsSet ON Individuals.Id = EnrollmentsSet.Enrollments_Individual
GROUP BY Individuals.Gender, Individuals.Ethnicity, EnrollmentsSet.SubProgram_Enrollments
HAVING (EnrollmentsSet.SubProgram_Enrollments = 2) OR
                  (EnrollmentsSet.SubProgram_Enrollments = 3) OR
                  (EnrollmentsSet.SubProgram_Enrollments = 4)
Order By Ethnicity, Gender
Query Results

Requested Format



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>