I have a employee table with EMPID, EMPNAME, DEPTID, SAL
and want to fetch the maximum and minimum salary on each
dept id with the emp name. Can anyone help in this? The
result should contain the EMPNAME, DEPTID, SAL.

Answers were Sorted based on User's Feedback



I have a employee table with EMPID, EMPNAME, DEPTID, SAL and want to fetch the maximum and minimum..

Answer / gayathri

Sel Empname,deptid, (qualify row_number() over (partition by deptid order by sal asec)=1) as min_sal, (qualify row_number() over (partition by deptid order by sal desc)=1) as max_sal from EMP

Is This Answer Correct ?    5 Yes 0 No

I have a employee table with EMPID, EMPNAME, DEPTID, SAL and want to fetch the maximum and minimum..

Answer / ragunath

sel empname,deptid,sal 
from employee where (deptid,sal) in 
(sel deptid, max(sal)from employee group by 1
)
union
(sel empname,deptid,sal 
from employee where (deptid,sal) in 
(sel deptid, min(sal) from employee group by 1
));

Is This Answer Correct ?    1 Yes 1 No

I have a employee table with EMPID, EMPNAME, DEPTID, SAL and want to fetch the maximum and minimum..

Answer / hariharan

sel empname, a.deptid, b.salary
from t1_metadata.emp_test a,
(
sel
deptid, max(sal)
from t1_metadata.emp_test
group by 1
union
sel
deptid, min(sal)
from t1_metadata.emp_test
group by 1
)b (deptid, salary)
where a.deptid = b.deptid
and a.sal=b.salary

Is This Answer Correct ?    8 Yes 11 No

I have a employee table with EMPID, EMPNAME, DEPTID, SAL and want to fetch the maximum and minimum..

Answer / syamal rao

You can try the bellow query in BTEQ of TERADATA.


select empname from employee with max(sal),min(sal) by deptid;

Is This Answer Correct ?    1 Yes 8 No

Post New Answer

More Teradata Interview Questions

How many sessions of MAX is PE capable of handling at a particular time?

0 Answers  


What are the uses of client software involved in teradata?

0 Answers  


any one pls tell me what are the table names in banking project?

2 Answers  


suppose one Cylinder split data blocks are moved from where?

1 Answers  


Please tell me a query to find the Primary key,Foreign key,primary Index,PPI for the Database?

5 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 collect State in Teradata ? what it use and how it works??

3 Answers   TCS,


What are the types of tables in Teradata

22 Answers   Cap Gemini, Cognizant, Infosys,


How to eliminate product joins in a teradata sql query?

0 Answers  


hi frnds i want to learn teradata utilities and teradata dba real time. i have 1+ years of experience in teradata. so i want to go deeply in Tearada. plz let me know at my email id who r best to learn from. im lookng for a realtime guy in HYD or Banglr. Thanks in advance. Rajesh my email-id: rajeshmss87@gmail.com

0 Answers   IBM,


What are the different table types supported by teradata?

0 Answers  


What are differences between teradata and ansi session modes in teradata?

0 Answers  


Categories