Query Help
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


Query Help Expand / Collapse
Author
Message
Posted 5/20/2007 2:52:59 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 9/7/2009 5:50:22 AM
Posts: 20, Visits: 40
Hi All,
I would like to eliminate duplicates and make the following table with unique records. I wish to have a query to solve such issues.

TableName : EMPLOYEE

EMPID EMPNAME EMPSSN
************************
1 Jack 555-55-5555
2 Joe 555-56-5555
3 Fred 555-57-5555
4 Mike 555-58-5555
5 Cathy 555-59-5555
6 Lisa 555-70-5555
1 Jack 555-55-5555
4 Mike 555-58-5555
5 Cathy 555-59-5555
6 Lisa 555-70-5555
6 Lisa 555-70-5555
. .... ...........
. .... ...........
. .... ...........

Note :
I dont have the rights to Create any Table
I dont have the rights to Add a new Column to the table
Im not suppose to use any other utils

I tried a Query using Row_Number() which makes the records unique but again i donno how to remove duplicates, Kindly help!

SELECT B.EMPID,
B.EMPNAME,
B.EMPSSN,
MIN(A.RID)
FROM
EMPLOYEE B,
(SELECT EMPID,
ROW_NUMBER() OVER (ORDER BY EMPID ASC) RID
FROM EMPLOYEE) A
WHERE
B.EMPID = A.EMPID
GROUP BY 1,2,3;


Cheers
Meem
Post #7526
Posted 5/20/2007 8:28:19 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/18/2007 8:56:00 PM
Posts: 5, Visits: 1
Hi Meem,

Try this:

SELECT EMPID, EMPNAME, EMPSSN FROM EMPLOYEE GROUP BY 1,2,3

It should remove all duplicates.

Post #7528
Posted 5/20/2007 8:47:22 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 9/7/2009 5:50:22 AM
Posts: 20, Visits: 40
Hi Mitrich,
Thanks for your reply!
It did worked but im in need of a Delete query which would produce the result similar to the one you mentioned.

Regards
Post #7529
Posted 5/20/2007 10:54:08 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/18/2007 8:56:00 PM
Posts: 5, Visits: 1
Try this
----------------------------------
create volatile multiset table test123 (
id integer
,name varchar(20)
) on commit preserve rows
;
insert into test123 (1, 'aaaa');
insert into test123 (1, 'aaaa');
insert into test123 (2, 'bbbb');
insert into test123 (2, 'bbbb');
insert into test123 (3, 'cccc');


insert into test123
select id, '##'||name as name
from test123
qualify row_number() over(partition by id order by id) = 1
;
delete from test123 where not name like '##%'
;
update test123 set name = substring(name from 3)
;
select * from test123
-----------------------------------------------------------

Post #7530
Posted 5/20/2007 11:36:01 PM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 9/7/2009 5:50:22 AM
Posts: 20, Visits: 40
Hi Mitrich,

Your script works!! I cant implement it bcoz i dont hav the rights to INSERT any new rows, can you advise please?

Regards.
Post #7531
Posted 5/21/2007 12:44:22 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/18/2007 8:56:00 PM
Posts: 5, Visits: 1
I don't see any other ways how to solve your problem.
Ask permission either to create table or insert rows.

This problem was disscused here:
www.teradataforum.com/teradata/20040505_182346.htm

Best regards,
Mitrich
Post #7535
Posted 5/25/2007 10:49:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/7/2009 8:33:47 AM
Posts: 2, Visits: 3
Perhaps I'm missing the point , but could you not just use select distinct?
Post #7631
Posted 5/31/2007 4:24:06 AM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 2/18/2008 4:01:01 AM
Posts: 30, Visits: 14
volatile table need more priviledge than just create tables :-)

Post #7678
Posted 6/4/2007 3:31:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/18/2007 8:56:00 PM
Posts: 5, Visits: 1
I used it only to show how it can be implemented.
In any case could you tell what kind of priviledges it require except create table?
Post #7712
Posted 6/4/2007 4:40:18 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 7/10/2009 6:28:52 PM
Posts: 505, Visits: 546
As a matter of fact, the user doesn't require create table privileges to create volatile table.
Post #7713
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 2:02am

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.063. 6 queries. Compression Disabled.