SQL Question about DISTINCT
|
Original Message
|
Name: kaztuba1
Date: November 12, 2007 at 19:35:08 Pacific
Subject: SQL Question about DISTINCTOS: XPCPU/Ram: 2GBModel/Manufacturer: DELL |
Comment: I have a empty table A that I am trying to populate. Insert into A(primary_key, Name) Select sequence.NEXTVAL, name From Table B The problem is that name in B have duplicate values and I cant use DISTINCT with SELECT because of the sequence. How do I make name distinct and still populate the primary key with the sequence.
Any help would be great!!! Thanks!!!
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mahesh Kumar
Date: November 18, 2007 at 19:52:06 Pacific
Subject: SQL Question about DISTINCT |
Reply: (edit)I am not sure but may be you can create another table C based on table B. Create table C SELECT DISTINCT name FROM table b; Then Insert into A(primary_key, Name) Select sequence.NEXTVAL, name From Table C Try if this works. Regards, Mahesh Kumar
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Razor2.3
Date: November 29, 2007 at 10:02:27 Pacific
Subject: SQL Question about DISTINCT |
Reply: (edit)I'm rusty with my SQL, but couldn't you do this? INSERT INTO A(primary_key, Name) SELECT sequence.NEXTVAL, name FROM SELECT DISTINCT name FROM B;
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: mwatterud
Date: February 19, 2008 at 09:42:40 Pacific
Subject: SQL Question about DISTINCT |
Reply: (edit)INSERT INTO A(Primary_key, Name) SELECT XX.NextVal ,XX.Name FROM (SELECT MIN(sequence.NEXTval) AS NextVal ,Name FROM TABLE B GROUP BY Name) XX
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: