Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 March 29th, 2004, 07:44 PM
Authorized User
 
Join Date: Oct 2003
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default eliminating duplicate data

Hi All,

I have the following table with 4 columns and 6 rows.

A B C NUMBER
X Y 234
     Z 234
     K 235
R 236
     M 237
L 237

I am trying to create a new table that eliminate the duplicate data under the "NUMBER" field. Here is the table that I would like to see after eliminating the duplicate data.

A B C NUMBER
X Y Z 234
         K 235
R 236
L M 237

Any help would be appreciated, thanks...
 
Old April 8th, 2004, 09:34 AM
Authorized User
 
Join Date: Oct 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SubodhKumar Send a message via Yahoo to SubodhKumar
Default

Tell Me,
What will u do when data will be like.
A B C NUMBER
X Y 234
   S Z 234
        K 235
R 236
        M 237
L N M 237

Or Many More.....



Quote:
quote:Originally posted by erin
 Hi All,

I have the following table with 4 columns and 6 rows.

A B C NUMBER
X Y 234
        Z 234
        K 235
R 236
        M 237
L 237

I am trying to create a new table that eliminate the duplicate data under the "NUMBER" field. Here is the table that I would like to see after eliminating the duplicate data.

A B C NUMBER
X Y Z 234
          K 235
R 236
L M 237

Any help would be appreciated, thanks...


Enjoy!
Subodh Kumar
Phoneytunes.com
 
Old April 22nd, 2004, 11:49 AM
Authorized User
 
Join Date: Apr 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

insert into NEWTABLE
select distinct '','','',NUMBER
from ORIGINALTABLE

Update NEWTABLE
SET N.A = O.A
FROM NEWTABLE N,ORIGINALTABLE O
WHERE O.NUMBER = N.NUMBER
AND O.A <> '' AND O.A is not NULL

Update NEWTABLE
SET N.B = O.B
FROM NEWTABLE N,ORIGINALTABLE O
WHERE O.NUMBER = N.NUMBER
AND O.B <> '' AND O.B is not NULL

Update NEWTABLE
SET N.C = O.C
FROM NEWTABLE N,ORIGINALTABLE O
WHERE O.NUMBER = N.NUMBER
AND O.C <> '' AND O.C is not NULL


syntax mightn't be 100% correct but you should get the idea.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminating duplicate records programmatically oldmainframehack Access VBA 39 July 27th, 2007 01:46 PM
Duplicate records while inserting the data ebindia0041 .NET Framework 1.x 0 May 23rd, 2007 07:15 PM
Duplicate Data IN DROPDOWNLIST. prasanta2expert ASP.NET 1.0 and 1.1 Professional 4 November 22nd, 2006 05:36 AM
prevent duplicate customers when importing data stoneman Access 1 August 6th, 2004 10:31 AM
Avoiding Displaying duplicate data saleaf10 Classic ASP Databases 1 November 26th, 2003 10:16 PM





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