MomentSurfer
IS-IT--Management
Greetings Everyone,
I have a "Project" table, a "UserAccount" table, and a "ProjectResource" table.
The ProjectResource table links a Project to a UserAccount. This is a many-to-many table.
I need to create a VIEW that displays the project information and ALSO displays the first two resources that are assigned (but only the first two). The assigned resources need to appear in columns that are on the same row as the project information.
How would you recommend to approach something like this? Joins would return multiple rows. I need the data consolidated on a single row. Would a sub-select be the approach? I'd rather avoid writing a stored procedure that uses a cursor to create a temp table, if possible.
Here is my sample data structure:
Project
- ProjectID
- ProjectName
UserAccount
- UserAccountID
- UserName
ProjectResource
- ProjectID
- UserAccountID
I want the output to be:
ProjectID, ProjectName, PrimaryResourceName, SecondaryResourceName
I'd appreciate any tips or sample queries you could provide.
Your help is greatly appreciated.
David
I have a "Project" table, a "UserAccount" table, and a "ProjectResource" table.
The ProjectResource table links a Project to a UserAccount. This is a many-to-many table.
I need to create a VIEW that displays the project information and ALSO displays the first two resources that are assigned (but only the first two). The assigned resources need to appear in columns that are on the same row as the project information.
How would you recommend to approach something like this? Joins would return multiple rows. I need the data consolidated on a single row. Would a sub-select be the approach? I'd rather avoid writing a stored procedure that uses a cursor to create a temp table, if possible.
Here is my sample data structure:
Project
- ProjectID
- ProjectName
UserAccount
- UserAccountID
- UserName
ProjectResource
- ProjectID
- UserAccountID
I want the output to be:
ProjectID, ProjectName, PrimaryResourceName, SecondaryResourceName
I'd appreciate any tips or sample queries you could provide.
Your help is greatly appreciated.
David