Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2004, 07:26 AM
Registered User
 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default sql query

hi to all
i want to display duplicate records using single sql query


 
Old September 28th, 2004, 07:29 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Love having good sql query

visit google.com and in the search box type ur question.

have a nice day

 
Old September 28th, 2004, 07:37 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma
Default

HI,

Well one way is to group records on the basis of all the columns on tables OR the coulnms on which you consider the row as duplicate.

if Table1 has col1,col2,col3,col4,col5 then u can use :-


Select Count(*) as [count],col1,col2,col3,col4,col5 from Table1
group by col1,col2,col3,col4,col5
having count(*)>1

Please be aware that if u have a large number of columns, its heavy to use.

But if u consider a row duplicate on the basis of col1,col2 then
this will server ur purpose.

Select Count(*) as [count],col1,col2
group by col1,col2having count(*)>1

Hope this helps.

B. Anant





Similar Threads
Thread Thread Starter Forum Replies Last Post
sql query i need seearam MySQL 7 November 30th, 2008 03:14 AM
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
SQL Query!! dpkbahuguna Beginning VB 6 5 October 12th, 2007 12:39 AM
Help with SQL query sattaluri Access 2 August 11th, 2006 09:26 AM
SQL query PinkyCat Classic ASP Databases 3 March 11th, 2005 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.