Solved

SQL Join Query Help

Posted on 2013-11-04
6
414 Views
Last Modified: 2013-12-05
I have a Training_Tasks table that looks like this:
ID  TaskDept   TaskName
01  Eng            JobPrep
02  Eng            JobCheck
03  Mill           BeamSaw
04  Mill           Cutting

and an Employee table that looks like this:
ID  Dept  Name
01  Eng    Mike
02  Eng    Paul
03  Mill    John

and the table to store my data for Task Training Hours looks like this:

ID  EmpID  TaskID   TotalHours   TrainingDate
01  01         01          1.5                  1/1/2013
02  01         04           6.5                 1/1/2013
03  02         02           8.0                  1/1/2013

... and so on...

I need a view the above table and see my Task Training Hours represented this way:
(see task name)

EmpDept   Employee     TaskDept   JobPrep     JobCheck    Cutting     TrainingDate
Eng            Mike                  Eng           1.5                                               1/1/2013
Eng            Mike                  Mill                                              6.5            1/1/2013
Eng            Paul                   Eng                             8.0                              1/1/2013


Basically I want a column split out per TaskName and the view needs to be editable.

Thank you for your help!
0
Comment
Question by:Bianca
6 Comments
 
LVL 22

Expert Comment

by:plusone3055
Comment Utility
interesting puzzle there
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
That would be a PIVOT, where rows are rows, data in one column becomes the columns on the return set, and the 'cell' intersect is an aggregate like SUM() or Count().

Click on the below link, and scroll down, for decent examples.
http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
0
 
LVL 4

Expert Comment

by:rdm4u
Comment Utility
You can use crosstab
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:Bianca
Comment Utility
I need the SQL view reflected that way. SQL Query...
0
 
LVL 40

Expert Comment

by:Sharath
Comment Utility
You have 7 columns in the expected result but the expected result has 5 columns of data only. How exactly you want the result set?
0
 
LVL 65

Expert Comment

by:Jim Horn
Comment Utility
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now