Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 29th, 2004, 07:44 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
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...
Reply With Quote
  #2 (permalink)  
Old April 8th, 2004, 09:34 AM
Authorized User
 
Join Date: Oct 2003
Location: Delhi, Delhi, India.
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
Reply With Quote
  #3 (permalink)  
Old April 22nd, 2004, 11:49 AM
Authorized User
 
Join Date: Apr 2004
Location: , , Ireland.
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.