I have this SQL:

SELECT [Course Section], [Instructor Name], [Respondent Code], [1], [2], [3], [4], [5]
FROM [sirssoctonlineforms].[dbo].[Denormalized_V]
where term = 'ss14' and subject = 'iss' and course like '%330%'
order by subject, course, [course section], [respondent code]

And the results are:

Respondent Code     1         2              3              4              5
1281172             Average   Above Average  Above Average  Above Average  NULL
1281172             NULL      NULL           NULL           NULL           Average

What I want to see is this:

Respondent Code     1         2              3              4              5
1281172             Average   Above Average  Above Average  Above Average  Average

Is there any way I can do this?

有帮助吗?

解决方案

SELECT [Course Section], [Instructor Name], [Respondent Code], 
       max([1]) as [1], 
       max([2]) as [2], 
       max([3]) as [3], 
       max([4]) as [4], 
       max([5]) as [5]
FROM [sirssoctonlineforms].[dbo].[Denormalized_V]
where term = 'ss14' and subject = 'iss' and course like '%330%'
group by [Course Section], [Instructor Name], [Respondent Code]
order by subject, course, [course section], [respondent code]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top