Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Displaying results of an SQL Pivot Query

Displaying results of an SQL Pivot Query

Displaying results of an SQL Pivot Query


Here's my problem statement: I'm using a query that uses the SQL Pivot function. But I'm having issues displaying the results.

Here's my query.


<cfquery name="showprofileresults"  datasource="#db#" username="#dbusername#" password="#dbpassword#">
    select *
      select pd.firstname + ' ' + pd.lastname as fullname,pr.participantemail,pr.meetingidnumber, pr.columnid,pd.firstname, pr.value
      from ProfileResults pr
      join participantdetails pd on pr.participantemail = pd.participantemail
      where pr.meetingidnumber = '#form.meetingnumber#' and pr.rowid not in(1,2,5,10,14,17)
    ) src
      for columnid in ([1], [2], [3],[4])
    ) piv

I get the following results


participantemail		meetingidnumber		1	2	3	4
someemail@gmail.com		CBE95597		NULL	NULL	NULL	NULL
aguy@corpinc.com		CBE95597		33	36	39	12
test@domain.ca			CBE95597		28	36	30	26 

I'm good with the results. The problem I am having is displaying the results in a <cfoutput> tag. Here's my display code.


<cfoutput query="showprofileresults">

And here are the results. I don't know how to refer to the pivot columns 1, 2, 3 and 4

RE: Displaying results of an SQL Pivot Query

I haven't used the pivot function but I would suggest using a cfdump to see the structure of the data.

If you can't stand behind your troops, stand in front of them.
Semper Fidelis


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close