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.
Answer Posted / joy
/* GENERAL*/
SELECT EMP_ID||''||AGE FROM EMP;
SELECT POSITION('A' IN NAME) FROM EMP;
SELECT INDEX(NAME,'SA') FROM EMP;
SELECT LOWER(NAME) FROM EMP;
SELECT UPPER(NAME) FROM EMP;
SELECT SUBSTR(name,2) FROM EMP;
/* TRIM */
SELECT TRIM(TRAILING 9 FROM AGE ) AS VIK FROM EMP;
SELECT TRIM(TRAILING '2' FROM AGE ) AS VIK FROM EMP;
SELECT TRIM(LEADING ' 8' FROM AGE ) AS VIK FROM EMP;
SELECT TRIM(BOTH '2' FROM (TRIM(LEADING ' ' FROM AGE )))
AS VIK FROM EMP;
SELECT TRIM(BOTH 'A' FROM AGE) AS VIK FROM EMP;
SELECT TRIM(AGE) FROM EMP;
SELECT TRIM(LEADING ' ' FROM AGE) FROM EMP;
SELECT TRIM(AGE) || NAME FROM EMP;
/* LENGTH */
SELECT CHARACTER_LENGTH(TRIM(NAME)) FROM EMP;
SELECT CHARACTERS(NAME) FROM EMP;
SELECT OCTET_LENGTH(NAME) FROM EMP;
/*DIRECTLY TAKE POSITION*/
SELECT
SUBSTR (NAME,
POSITION('A' IN NAME ))
FROM EMP;
/*REMOVE SPACE*/
SELECT
SUBSTR (
TRIM( NAME),2)
FROM EMP;
SELECT SUBSTR(NAME,2) FROM EMP;
/* SUM WITH PARTITION BY AGE*/
select name ,age, salary, sum(salary) over (partition by
age order by DOJ ) from emp ;
/*CUMULATIVE SUM WITH PARTITION BY AGE*/
select name,age, salary, sum(salary) over (partition by age
order by DOJ rows unbounded preceding ) from emp ;
/*CUMULATIVE SUM */
select name,age,salary, sum(salary) over ( order by DOJ
rows unbounded preceding ) as casum from emp ;
/* AVG WITH PARTITION BY AGE*/
select name ,age, salary, AVG(salary) over (partition by
age order by DOJ ) from emp ;
/*CUMULATIVE AVG WITH PARTITION BY AGE*/
select name,age, salary, AVG(salary) over (partition by age
order by DOJ rows unbounded preceding ) from emp ;
/*CUMULATIVE AVG*/
select name,age,salary, AVG(salary) over ( order by DOJ
rows unbounded preceding ) as casum from emp ;
/*Rank*/
SELECT emp_id,name,salary,age,
rank() over ( partition by name order by salary desc ) as
ranks
from emp ;
/*Rank with Order by*/
SELECT emp_id,name,salary,age,
rank() over ( order by salary desc ) as ranks
from emp ;
/*Rank With Qualify*/
SELECT emp_id,name,salary,age,
rank() over ( partition by name order by salary desc ) as
ranks
from emp
qualify ranks <=2;
/*ROw_number*/
SELECT emp_id,name,salary,age,
ROW_NUMBER() over ( partition by name order by salary
desc ) as RowNUMBER
from emp;
/*ROw_number with only order by*/
SELECT emp_id,name,salary,age,
ROW_NUMBER() over ( order by salary desc ) as RowNUMBER
from emp
/*ROw_number with Qualify*/
SELECT emp_id,name,salary,age,
ROW_NUMBER() over ( partition by name order by salary
desc ) as RowNUMBER
from emp
qualify rownumber <=2;
Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
While creating table my dba has fallback or no fallback in his ddl. What is that?
What is the use of teradata system software?
Why are oltp database designs not generally a good idea for a data warehouse?
What are the commands to make a new table, change a table and remove a table in teradata?
What is the difference between teradata and oracle?
What is a sparse index?
How can bottlenecks be identified?
What are the different functions performed in development phase?
What do you mean by parsing?
How do you see a ddl for an existing table?
Explain fastload in teradata?
Explain teradata architecture?
What are the updated features of teradata?
What is the purpose of joins in teradata?
How do you verify a complicated sql?