Need a help to find the 3rd person minimum salary in the salary table of Teradata.

Database
N/A

Need a help to find the 3rd person minimum salary in the salary table of Teradata.

Here is i am trying to execute the below query in teradata using level but it giving me error. Please help me to resolve this issue.

 

SELECT LEVEL,MIN(SAL) FROM EMP
WHERE LEVEL = 2
CONNECT BY PRIOR  SAL < SAL
GROUP BY LEVEL

 

Thanks,

Srin.

 


Accepted Solutions
N/A

Re: Need a help to find the 3rd person minimum salary in the salary table of Teradata.

There's no need for recursion to get the 3rd lowest salary, this is a simple task for DENSE_RANK:

SELECT SAL
FROM EMP
QUALIFY
    DENSE_RANK() OVER (ORDER BY SAL) = 3

 

1 ACCEPTED SOLUTION
4 REPLIES
Teradata Employee

Re: Need a help to find the 3rd person minimum salary in the salary table of Teradata.

I'm not sure what you are trying to do, but Teradata (and DB2, and ANSI Standard SQL) use recursive Common Table Expressions (CTEs) instead of Connect-By, which is Oracle-specific syntax.  For details and examples, go to

http://info.teradata.com/HTMLPubs/DB_TTU_16_00/index.html#page/SQL_Reference%2FB035-1146-160K%2Firv1...

 

Then click Select, the WITH Statement Modifier.  Or just go to info.teradata.com and download the SQL DML manual.

N/A

Re: Need a help to find the 3rd person minimum salary in the salary table of Teradata.

There's no need for recursion to get the 3rd lowest salary, this is a simple task for DENSE_RANK:

SELECT SAL
FROM EMP
QUALIFY
    DENSE_RANK() OVER (ORDER BY SAL) = 3

 

N/A

Re: Need a help to find the 3rd person minimum salary in the salary table of Teradata.

Thanks. Just i want to know the recursive query syntax in teradata.

N/A

Re: Need a help to find the 3rd person minimum salary in the salary table of Teradata.

Thanks. Can you please tell the recursive query syntax in teradata.