473,463 Members | 1,552 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

exclude query

I have 16,000 rows in tblClient and 3000 rows in NewTable.

SELECT tblClient.*
FROM tblClient INNER
JOIN [New Table] ON tblClient.NoDossier <> [New Table].NoDossier

if I use = (equal) instead of <> (exclude), the query returns 3000 rows

when I use <> it returns 160000 rows,
if I try group by, the query bugs

what is my problem
Jul 23 '05 #1
4 5951

To eliminate duplicate rows use:
-------------------------------------------------------

SELECT DISTINCT tblClient.*
FROM tblClient INNER
JOIN [New Table] ON tblClient.NoDossier <> [New Table].NoDossier
To use group by:
---------------------------------------------------------

SELECT DISTINCT tblClient.col1, tblClient.col2, ......
FROM tblClient INNER
JOIN [New Table] ON tblClient.NoDossier <> [New Table].NoDossier
GROUP BY tblClient.col1, tblClient.col2,.......
*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #2


text, ntext or image cannot be selected as distinct

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #3
You should have mentioned that earlier!
*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #4
Fernand St-Georges (fe****************@videotron.ca) writes:
I have 16,000 rows in tblClient and 3000 rows in NewTable.

SELECT tblClient.*
FROM tblClient INNER
JOIN [New Table] ON tblClient.NoDossier <> [New Table].NoDossier

if I use = (equal) instead of <> (exclude), the query returns 3000 rows

when I use <> it returns 160000 rows,
if I try group by, the query bugs

what is my problem


Using <> as a joining operator is very rarely useful. Say that the number
of rows in tblClient is 163 and in [New Table] have 1000 rows. That makes
up for a total of 163000 possisble combinations. You condition filters out
those 3000 where NoDossier are equal.

What you probably want is:

SELECT c.*
FROM tblClient c
WHERE NOT EXISTS (SELECT *
FROM [New Table] n
WHERE c.NoDossier = n.NoDossier)

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
9
by: paul.jameson | last post by:
I have a simple Access database that stores Karaoke Songlists for my local pub. From this you are able to print out the song lists they use. Up until now, any duplicate songs that appear on say,...
0
by: starman7 | last post by:
i want to exclude email addresses which are in newsletter_email_addresses which also appear in mooky_private.sign_ups.email and mooky.newsletter_opt_outs.email. my query seems to exclude the...
2
by: Arsen V. | last post by:
Hi, How to exclude the App_Data directory from Visual SourceSafe? It appears that Vs 2005 automatically adds the App_Data directory with the large binary MDF and LOG files to the Visual...
4
by: ninrulz | last post by:
I have been working on a database to perform some of the tasks that I have been doing manually in Excel. One of those tasks is to sort and exclude duplicate data. The fields are as follows ...
2
by: Mirnes | last post by:
I have a listbox which is populated from Sql query and I use it to add values to table. I would like to exclude value which just has been added from listbox. Since it is impossible to do in query...
8
by: tonsam | last post by:
I have a report (monthly inventory) whose record source is based on a query named monthly_inventory_qry. On same query (monthly_inventory_qry), I add two fields (month_1 and month_2)and its sum was...
1
by: bips2005 | last post by:
i have got two tables,one customer with fields cust_id,email and another with field cust_id,domname,expirydate. i have this query to combine these two tables to give me email and the expirydate as ...
6
by: Dan2kx | last post by:
Good aft peeps, i have a a working solution for this already but i suppose you could say it is a bit lazy, I have used ADezii's calendar to display dates in my own unique way using the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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...
0
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 ...

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.