Convert Rows to Column --- Can any one help ?

  • Hi,

    I am running a simple query which is pulling count of members and the forms,

    I need to convert the formnames as columns.... Can any one help ...

    Here is what my query and data looks like

    Select Count(Distinct memberid) as NoOfMembers ,formname as Formname from tblmemberforms where appdate between '8/01/2009' and '8/31/2009'

    Group by Formname

    NoOfMembers Formname

    34 DAS

    40 HealthAssessmentQuestionnaire

    48 LifetimeAuthorization

    39 PatientReceipt

    THE END RESULT Should be

    DAS HealthAssessmentQuestionnaire LifetimeAuthorization PatientReceipt

    34 40 48 39

    Thanks

  • I would look at the PIVOT/UNPIVOT functions in BOL, also you can use CASE statements to return the data you're wanting in a specific column position.

    MJM

  • You can also take a look at the Cross Tab and Pivot articles linked in my signature line. They give you options in addition to the PIVOT function provided.

  • Thanks, But can you write a sample query lafter ooking at my query.

  • Thanks, But can you write a sample query lafter ooking at my query.

Viewing 5 posts - 1 through 4 (of 4 total)

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