September 28, 2009 at 3:34 pm
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
September 28, 2009 at 3:53 pm
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
September 29, 2009 at 9:35 am
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.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
September 29, 2009 at 2:07 pm
Thanks, But can you write a sample query lafter ooking at my query.
September 29, 2009 at 2:08 pm
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