Anyone know how I can loop through the following select statement? I get multiple rows for a user if they have a value in all the following fields [CDM Master Access], [KnowledgeMaster Access], [Knowledge Source Access]. I'm trying to get it all to just show on one row .



Code:
Select a.UserID        
        ,b.Username
        ,b.FirstName
        ,b.LastName         
        ,a.HospID        
        ,d.HospName
       -- ,a.productareaid

        ,[CDM Master Access]=
        
           CASE 
              WHEN c.ProductAreaName= 'BPI.Net' THEN 'CDM Master'
     
              END
        ,[KnowledgeMaster Access]=
        
           CASE 
              WHEN c.ProductAreaName= 'BPI KnowledgeMaster' THEN 'KnowledgeMaster'
          
              END
         ,[KnowledgeSource Access]=
        
           CASE 
              WHEN c.ProductAreaName= 'Knowledge Product' THEN 'Knowledge Source'
           
              END            
        ,max(logtime)               as Last_Login
        ,count(*)                   as Num_Of_Sessions_to_CurrDate