Skip to content
Advertisement

Combine SQL Data into 1 row

I’m attempting to build code to create an SSRS report. The folder type ID 19 indicates a Member ID. If the Folder type ID includes a *1300 it indicates a provider ID that is located in that field, prior to the *1300. The issue with how I am currently doing it is that it is creating 2 rows. One where the Provider ID is populated but the Member ID is showing as NULL. The other where the Member ID is populated but the Provider ID is showing as NULL. What I want to do is combine them so I’m only returning 1 row, with both the Member ID and the Provider ID populated correctly. What is the best way to go about this? Thanks in advance for any assistance!

Advertisement

Answer

You can group by all the columns that you select and aggregate on the columns that you want to combine into 1 row:

I also removed ELSE null from both CASE statements because it is redundant.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement