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.
| 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 AWorker_Name Order_Job Repeat_Job_NumMike AB1 NullJohn AB2 AB1James AB3 NullI 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? |
 |
|
|
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. |
 |
|
|
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 @TableSELECT 'Mike', 'AB1', NullUNION ALL SELECT 'John', 'AB2', 'AB1'UNION ALL SELECT 'James', 'AB3', NullSELECT A.Worker_NameFROM @Table AS AINNER JOIN @Table AS B ON A.Order_Job = B.Repeat_Job_Num[/code] |
 |
|
|
|
|
|