...

View Full Version : How can I loop through a select Statement



mgreen84
10-19-2009, 05:59 PM
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 .





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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum