Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Filtering Issues

Author  Topic 

DaveyB
Starting Member

10 Posts

Posted - 2008-06-27 : 08:56:55
I have a table, and what I want to do is find the person who caused the repeat.

(In this case for Job_Num AB2 Mike was the one who caused the repeat)

How would I go about displaying Mikes information (Name, Order_job, Repeat_Job_Num etc?

Table A
Worker_Name Order_Job Repeat_Job_Num
Mike AB1 Null
John AB2 AB1
James AB3 Null

I hope you can help!


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-27 : 09:37:06
Didnt understand how Mike caused reapeat. whats repeated here? Can you explain wat you mean by repeat?
Go to Top of Page

DaveyB
Starting Member

10 Posts

Posted - 2008-06-27 : 09:44:09
*EXPLANATION*
Johns Job (AB2) was the second Job that was done, Mikes Job (AB1) was the one that failed CAUSING the repeat. You can see AB1 in the repeat_job_num. What I want to do is look and find all the faults in Repeat_Job_Num and use that reference to search through the Order_Job table to get that record information.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-06-27 : 16:18:25
[code]DECLARE @Table TABLE (Worker_Name VARCHAR(50), Order_Job VARCHAR(3), Repeat_Job_Num VARCHAR(3))

INSERT @Table
SELECT 'Mike', 'AB1', Null
UNION ALL SELECT 'John', 'AB2', 'AB1'
UNION ALL SELECT 'James', 'AB3', Null

SELECT
A.Worker_Name
FROM
@Table AS A
INNER JOIN
@Table AS B
ON A.Order_Job = B.Repeat_Job_Num[/code]
Go to Top of Page
   

- Advertisement -