Hey Guys,
Total Number of Records (Based on 5 fields): 1000
Total Unique Records (Based on 5 Fields): 990
Total number of fields: 5
I have question regarding extracting duplicates from the dataset. I
have 2 fields that makes a record unique. I have used group by
function to find duplicates and got 10 records that are duplicating.
Each records duplicating 1 times, thus, 10 unique records and 10
duplicates, giving me 990 unique records out of 1000.
Now, I want to filter out duplicates from the dataset and get unique
records, including all 5 fields. Here is the query that I used.
select *
from (
select field1, field2, count(*)
from table 1
group by field 1, field2
having count(*) >1
)a,
table 1 b
where a.field1=b.field1 and a.field2=b.field2
When I use this query, it gives me duplicate records as i am matching
on both fields that makes records unique. Is there anyway to just
extract unique records?
Thank you very much for your help.
--AP 4 3003
On Fri, 28 Dec 2007 10:13:43 -0800 (PST), ap******@gmail.com wrote:
>Now, I want to filter out duplicates from the dataset and get unique records, including all 5 fields.
I'm not at all clear what you are trying for, but perhaps adding
DISTINCT to your query will do it.
Roy Harvey
Beacon Falls, CT
On Fri, 28 Dec 2007 10:13:43 -0800 (PST), ap******@gmail.com wrote:
>Now, I want to filter out duplicates from the dataset and get unique records, including all 5 fields. Here is the query that I used.
(snip)
Hi AP,
Your problem is not clear to me. I suggest that you post your table
structure (as a CREATE TABLE statement, including constraints,
properties and indexes), a few well-chosen rows of sample data (as
INSERT statements) to illustrate the problem, and the output required
from that sample data. See www.aspfaq.com/5006 for more details.
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
(ap******@gmail.com) writes:
Now, I want to filter out duplicates from the dataset and get unique
records, including all 5 fields. Here is the query that I used.
select *
from (
select field1, field2, count(*)
from table 1
group by field 1, field2
having count(*) >1
)a,
table 1 b
where a.field1=b.field1 and a.field2=b.field2
When I use this query, it gives me duplicate records as i am matching
on both fields that makes records unique. Is there anyway to just
extract unique records?
Could this do?
SELECT a.*
FROM tbl a
WHERE EXISTS (SELECT *
FROM (SELECT field1, field2
FROM tbl
GROUP BY field, field2
HAVING COUNT(*) 1) AS b
WHERE a.field1 = b.field1
AND a.field2 = b.fiedl2)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Please post example DDL. It seems like a insert...select distinct query
would get your results if all columns for each duped row is exactly the same
--
Sincerely,
John K
Knowledgy Consulting, LLC
knowledgy.org
Atlanta's Business Intelligence and Data Warehouse Experts
<ap******@gmail.comwrote in message
news:96**********************************@e6g2000p rf.googlegroups.com...
Hey Guys,
Total Number of Records (Based on 5 fields): 1000
Total Unique Records (Based on 5 Fields): 990
Total number of fields: 5
I have question regarding extracting duplicates from the dataset. I
have 2 fields that makes a record unique. I have used group by
function to find duplicates and got 10 records that are duplicating.
Each records duplicating 1 times, thus, 10 unique records and 10
duplicates, giving me 990 unique records out of 1000.
Now, I want to filter out duplicates from the dataset and get unique
records, including all 5 fields. Here is the query that I used.
select *
from (
select field1, field2, count(*)
from table 1
group by field 1, field2
having count(*) >1
)a,
table 1 b
where a.field1=b.field1 and a.field2=b.field2
When I use this query, it gives me duplicate records as i am matching
on both fields that makes records unique. Is there anyway to just
extract unique records?
Thank you very much for your help.
--AP
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gnaneshwar Babu |
last post by:
Hi
I am facing a problem with extracting event logs of win32 to a file.
Am using the following code to extract eventlogs to file
use Win32::EventLog;
$handle=Win32::EventLog->new("System",...
|
by: kj |
last post by:
When I run the attached query, I get duplicates when there is one to
many relationship between tableA and tableB. The query, tested schema
and the result is attached. Sorry for the long post.
...
|
by: Shawn |
last post by:
Hi guys,
I'm trying to compose a query that will select all columns from a
table, but without any duplicates.
E.g.
table name is 'tblShipment'
columns are:
fldUnique(pk) | fldShipNo |...
|
by: paul |
last post by:
Hiya everyone,
I have two tables in SQL 2000. I would like to append the contents of
TableA to TableB.
Table A has around 1.1 Million Records.
Table B has around 1 Million Reocords.
...
|
by: Drew |
last post by:
I have a permission tracking app that I am working on, and I have made the
insert page for it. I am having issues on how to prevent duplicates from
getting entered.
Currently the interface for...
|
by: AK |
last post by:
Hi
Our product uses MS-SQL Server 2000. One of our customer has 10
installations with each installation stroring data in its own database.
Now the customer wants to consolidate these databases...
|
by: mGracz |
last post by:
Welcome,
how can I alter following table in order to reduce neighbouring
duplicates (symbol, position, quantity, price).
Nr Symbol Position Quantity
Price ...
|
by: Radu |
last post by:
Hi.
I have a "union" table which results of a union of two tables.
Occasionally I could have duplicates, when the same PIN has been added
to both tables, albeit at different Datees/Times, such...
|
by: ryan.paquette |
last post by:
In the table there are 2 fields in which I wish to limit (i.e. No
Duplicates)
Although I do not want to limit them to "No Duplicates" separately.
I need them to be limited to "No Duplicates" as...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
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...
| |