0

I am new to functions so am having a bit starting trouble here

I have two tables like this

Bugs

BugID | Title | ProjectName | CreatedBy

BugHistory

BughistoryID | BugID | Assignedto | ToStatus | FromStatus

EmployeeTable

EmployeeID | EmployeeName |

[AssignedTo] column from BugHistory is a foreign key for [EmployeeId] in EmployeeTable.

I want a select statement where I have to show the bugs table in gridview with [AssignedTo] and [Tostatus] columns from BugHistory table. How can I use functions for this both procedure s any ideas please?

In Assigned to column I want the name of the employee - how can I map this?

1 Answer 1

2

It sounds like you want this:

SELECT b.BugId
    , b.Title
    , b.ProjectName
    , b.CreatedBy
    , e.EmployeeName As AssignedTo
    , bh.ToStatus
FROM Bugs b
INNER JOIN BugHistory bh
    ON b.bugid = bh.bugid
INNER JOIN Employee e
    ON bh.AssignedTo = e.EmployeeId
Sign up to request clarification or add additional context in comments.

2 Comments

@blufeet CreatedBy is also an foreign key to EmployeeID
@anilkumar what do you mean no luck? Can you create a SQL Fiddle with some sample data?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.