moved the recrods to column headings

  • Hi Team,

    Please help with this requriement.

    The result of the below query is coming as

    CostCentre CategoryName TypeName Number of Incident

    5678 Care Fall-Wit 5

    5334 Care Fall-Not Wit 6

    Desired Output is

    CostCentre Category Name Fall-Wit Fall-Not Wit

    5678 Care 5 0

    5334 Care 0 6

    How can I acheive this?

    Select ReferenceCode2 CostCentre, CategoryName, TypeName, COUNT(EventID)NumberOfIncidents from Event

    inner join EventType on Event.EventTypeRef = EventType.EventTypeID

    inner join EventCategory on EventType.EventCategoryRef = EventCategory.EventCategoryID

    inner join Client on Event.ClientRef = Client.ClientID

    Where

    EventDate between '2014-02-01' and '2014-03-01'

    AND CategoryName = 'Care'

    and typename like '%fall%'

    Group by ReferenceCode2, CategoryName, TypeName

    Order by ReferenceCode2

  • I made it through using the case statement...

    FallNotWitnessed = ISNULL(Sum(Case when TypeName ='Fall - Not Wit' then 1 end),0),

    FallWitnessed = Isnull(Sum(Case when TypeName ='Fall - Witn' then 1 end),0),

    Regards,

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply