I'm working with medical claims where a single claim number can have up to 75 lines. Each claim has a code that predicates how the claim is handled and what I need to do for both stats and efficient case processing is combine all these lines together and grab just the unique values- some claims can have 20-30 lines with the exact same codes and i would obviously just need to know what those two codes are, not each individual line. I feel like this is a simple solution but it's just escaping my grasp.
Original Data:
Claim Number    EX1 Ex2 Ex3 Ex4 Ex5 Ex6
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
123456789123    LP  DU  1O            
123456789123    LP  DP  AP  1O        
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
123456789123    LP  DU  1O            
Select Distinct:
Claim Number    EX1 Ex2 Ex3 Ex4 Ex5 Ex6
123456789123    LP  DP  AP  1O        
123456789123    LP  DU  1O            
123456789123    LP  IK  D3  AP  1O    
But what I'm looking for would be something like
Claim Number    Codes
123456789123    LP,DP,AP,1O,DU,IK,D3  
The only solution I can think of is to create a big text string by adding a row column, putting them in their own table/subquery, and adding those together but i'd still get all the EX codes duplicated. Plus I don't know how many distinct lines a claim might have so the code would be repetitious and long for that many. I would be able to search for specific claims if i just made the codes into a long text string but i feel like there has t0 be a more elegant solution.
I've tried searching for this question but maybe I don't know exactly what I'm looking for, so I'm sorry if this is a repeat of something that's been asked already. I should also say any sql i've learned has largely been based on what I've needed to do so if this question is basic I apologize >.>
 
     
    