473,714 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newbie: Find unique records

5 New Member
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,apsta tid 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 1178
taoh15
5 New Member
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

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

Similar topics

16
2077
by: Justin Hoffman | last post by:
This is a question concerning query optimisation. Sorry if it's a bit long, but thanks to anyone who has the patience to help - This is my first post here... If I have two tables: 'tblContact' and 'tblCategory' where categories are like: Code Name 010101 Short 010102 Fat
3
4575
by: Phil | last post by:
I am looking to set up a hyperlink control on a form to retrieve letters that correspond to a record on a form. That is, there may be 100 form records, and I would like each of those form records to have a hyperlink button or control on it. that when pushed, pulls up the unique Word document associated with that form record. In this example, there would 100 unique letters associated with 100 unique form records. I tried working with...
3
1803
by: N J | last post by:
Hi, I want my form to tell me if there are similar records based on a certain field. For example, I currently have a record open on my form with 123@abc.com as a data in a field. I want the form to search the table for any other records with that same data in that field and tell me in a text box....'This is an existing customer' if there is 2 or more records, or 'This is a new customer' if there is just one record. TIA
9
5059
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ******************************************************************************* <asp:DataGrid visible="False" border=1
2
1740
by: ET | last post by:
Hi! I'll need help on what todo with this information in table... There has to be a unique on one column (Item ID, for inventory purpose) but in many cases that ID is not known... thus, many empty records for that column exist in a table. I tried to create unique index (no duplicates), of course, it failed because of many empty records... Now, is there ANY way to keep those empty records, and allow new empty
3
2587
by: fong.yang | last post by:
I have tried to use the query wizard to find unmatched records but it doesn't seem to be going right. The results are still giving me some records that are in both tables. I have two tables OriginalShops and AddedShops. Both tables have the same information in them. I want to find only records that are not contained it either tables. The following is the SQL statement created from the wizard: SELECT AddedShops.shop_name,...
7
4537
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent records. Should I design a new form for this or can I somehow make this work in the same form. Thanks in advance, john
1
2485
by: aknoch | last post by:
My basic situation is this - I ONLY want duplicates, so the opposite of DISTINCT: I have two tables. Ordinarily, Table1ColumnA corresponds in a one to one ratio with Table2ColumnB through a shared variable. So if I query TableB using the shared variable, there really should only be on record returned. In essence, if I run this and return TWO rows, it is very bad: select * from TableB where SharedVariable = 1234
2
4447
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for statistical purposes. I've been using Here's the situation: I have two main tables:
0
8715
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9322
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9189
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9037
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5964
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4470
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4734
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3170
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.