469,343 Members | 5,623 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

Newbie: Find unique records

5
Hi All

Although I have been using SQL2K for a number of years this is my first venture into more complicated stuff.

I have a query

SELECT apd.elid , apd.pcid , apd.apstatid , ap.empid
FROM ap RIGHT OUTER JOIN
ar ON ap.apid = ar.apid RIGHT OUTER JOIN
apd ON ar.arid = apd.arid
WHERE ap.empid IN (
SELECT emp.empid FROM emp LEFT OUTER JOIN
jt ON emp.empjt = jt.jtid
WHERE
(
emp.empislive = 1
)

Which works correctly, unfortuneately about 80% of what it produces are duplicate records - this is correct but I need to only have a set of
records which contain unique values for elid,pcid,apstatid and empid.

This is part of a set of routines which run once a day are are current handled by an external Application but it takes about 3 hours to run which is unacceptable on a 24x7 DB

How can I speed this up?

Thanks
Mar 1 '08 #1
1 1064
taoh15
5
Sorry All Ignore my question.

As soon as I finished the post I realised the answer.
My excuse it that I am try to understand somebody elses code and my original question was going to be about a problem later on in the routine but as I wrote the post I realised I was going to ask the wrong question.

Definately a case of not seeingthe wood from the trees:-)
Cheers
Taoh
Mar 1 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Justin Hoffman | last post: by
9 posts views Thread by tshad | last post: by
3 posts views Thread by fong.yang | last post: by
2 posts views Thread by srusskinyon | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.