March 11, 2016 at 12:51 pm
We currently have 2 separate tables to capture project information and sales credit for those projects. The project table would have 1 rown but the sales credit table could have multiple rows with different people getting credit for working on a project. I am trying to develop a query to pull all credit rows for that given project into 1 row. Below are samples of what my tables would look like.
Table 1:
Proj_no Proj_desc Proj_Status
100000 test O
100001 test2 O
Table 2:
Proj_no Emp_no Credit %
100000 100 50
100000 200 25
100000 300 25
100001 400 100
Expected Results
Proj_no Emp_no1 Credit 1 Emp_no2 Credit 2 Emp_no 3 Credit 3
100000 100 50 200 25 300 25
100001 400 100
Any guidance would be appreciated
Thanks
TOm
March 11, 2016 at 1:01 pm
why do you need to do this?
if you had 20 people involved in a project, then that would create 40 columns......who/what is going to use this output?
edit: typo
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
March 11, 2016 at 1:07 pm
This type of request is usually best done in the presentation layer, such as SSRS or even an Excel Pivot Table.
If you insist on doing it in SQL you'll need to do a crosstab/pivot, and, depending on your requirements, it may need to be a dynamic crosstab/pivot.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 11, 2016 at 1:32 pm
as a suggestion...please refer to your similar question below (2 years ago)
http://www.sqlservercentral.com/Forums/FindPost1549885.aspx
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply