• You can use CROSS TABS to achieve the results

    SELECTRIGHT(CONVERT(VARCHAR, CCD.startDateTime , 106), 8) AS startmonth,

    SUM( CASE WHEN CCD.contactDisposition = 1 THEN 1 ELSE 0 END ) AS 1

    SUM( CASE WHEN CCD.contactDisposition = 2 THEN 1 ELSE 0 END ) AS 2

    FROMContactCallDetail CCD,

    ContactQueueDetail CQD

    where

    CCD.sessionID=CQD.sessionID

    and CCD.sessionSeqNum=CQD.sessionSeqNum

    and CCD.profileID=CQD.profileID

    and CCD.nodeID=CQD.nodeID

    and CCD.applicationName='FLVS'

    and CCD.contactType=1

    and contactDisposition in (1,2)

    and CCD.startDateTime >='2011-01-01 00:00:00.000'

    and CCD.startDateTime <='2011-12-31 00:59:59.000'

    GROUP BY RIGHT(CONVERT(VARCHAR, startDateTime , 106), 8)

    ORDER BY 1

    The below mentioned articles will give you more idea on CROSS TABS and PIVOTS

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    http://www.sqlservercentral.com/articles/Crosstab/65048/


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/