Avatar of Torrwin
Torrwin
Flag for United States of America asked on

Create a pseudo-pivot query for a report

Hello,

I have table with widgets and a table with tasks.  Each widget has one of each of the tasks, none get left out.

The tables look something like so:

tblWidget
Widget_ID INT

tblTask
Task_ID CHAR(5)
Task_Name VARCHAR(50)

tblWorkflow
Widget_ID INT
Task_ID CHAR(5)
Completion_Date DATETIME

Currently I can run a query on tblWorkflow and see my data like so:
Widget ID          Task ID           Completion_Date
1                         1                     1/1/13
1                         2                     1/2/13
2                         1                     3/1/13
2                         2                     3/2/13
...etc...

However, I'd like to create a query that pivots the data so all my task names are listed horizontally across the top and my widgets are listed vertically on the side like so:
Widget ID          Task #1          Task #2          Task #3
1                         1/1/13            1/2/13            1/3/13
2                         3/1/13            3/2/13            3/3/13
...etc...

The results should  dynamically pick up any new tasks as they are added so they don't need to be added manually.

Any thoughts?

Thanks in advance.
Microsoft SQL ServerMicrosoft SQL Server 2008Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Torrwin

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
chaau

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Torrwin

ASKER
You are a genius, thanks so much!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy