Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write a single SQL to delete duplicate records from the a
single table based on a column value. I need only Unique
records at the end of the Query.

Answers were Sorted based on User's Feedback



Write a single SQL to delete duplicate records from the a single table based on a column value. I ..

Answer / nunna

Query to find duplicates in a table:(Custname, Prod,
Order_amt)

select custname,count(*) from sales1 a where a.rowid > ANY
(select b.rowid from sales1 b where a.custname=b.custname
and a.prod=b.prod and a.order_amt=b.order_amt) group by
custname;

Query to delete duplicates:

delete from sales1 a where a.rowid > ANY (select b.rowid
from sales1 b where a.custname=b.custname and a.prod=b.prod
and a.order_amt=b.order_amt);

Is This Answer Correct ?    7 Yes 15 No

Write a single SQL to delete duplicate records from the a single table based on a column value. I ..

Answer / manny

One need have atleast a unique column such as timestamp col
(and assumption is to keep lowest tmpstmp) OR some key col
say IPID (again keep lowest value)..

One determined - Have a nested Select on all rows (except
that key col) with group by rest of the columns + having
count(*) > 0 + aggreate MIN(key_col).

Now said that, have another outer SEL on all columsn &
do a inner join with above nested Sel .. WHERE outer
key_col <> MIN value of nested SEL..

See if it works..

Is This Answer Correct ?    5 Yes 16 No

Write a single SQL to delete duplicate records from the a single table based on a column value. I ..

Answer / milind

Nested query method might be required in other databases
how ever in TD we don’t need to follow such a difficult way
to just find out the unique rows.

In TD we have functions like Rank () and Rownum() in the
combination of Qualify, helps you to select out the rows
which you wants to delete.

you can add a condition like ‘Where Rank() > 1’

Is This Answer Correct ?    3 Yes 16 No

Post New Answer

More Teradata Interview Questions

What are the various indexes in teradata? How to use them? Why are they preferred?

0 Answers  


Pls any body reply for this question. Which circumstance does the optimizing choose a product join? Thanks for advance

6 Answers   Cap Gemini,


What is the use of fallback?

0 Answers  


Why Multiload does not supports USI and supports NUSI?

4 Answers  


TCS recently asked this question I have records like below Emp id Empname Salary DateTimestamp 1 AA 6000 20120609:11:30 1 AA 7000 20120609:12:30 1 AA 8000 20120609:01:30 I want to exceute records max timestamp(20120609:01:30)

2 Answers   TCS,


What is meant by a Highest Cost Plan?

0 Answers  


can we have an unconnected lkp to lookup a DB2 record against a Teradata record?

3 Answers  


Frnds.... i have one doubt we have the num like this +913757575......i want to remove 91 and i want lo load remaining data to the target table.. whinch function we can use in teradata????? Plz let me know.. thanks in advance

2 Answers  


what is the difference between bpo and call centre?

2 Answers   American Solutions,


What are teradata utilities?

0 Answers  


sel a.t1,b.t1 from emp a left outer join dept b ON a.id=b.id where b.deptno=10; sel a.t1,b.t1 from emp a left outer join dept b ON a.id=b.id and b.deptno=10; what is the difference on the above 2 queries?

3 Answers   CTS,


Describe the between keyword in teradata?

0 Answers  


Categories