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

What is meant by MATCHTAG in multiload utility?

2 Answers   Satyam,


How to improve the query performance without taking the collect statistics? In explain plan i have 'NO CONFIDENT'.

2 Answers  


I want to load 1000 rcds using. FL for every 100 records there is a check point.But script failed at 120 records, when we are restarting the script, it starts from last ckpt, but Target table contains populated data but FL doesnt support existing data in target table. How can we load data in FL?

4 Answers   IBM,


What is differnce between Error code and Error Level in Bteq

6 Answers   IBM,


how to load or extract the error table data ?

3 Answers  






How can we load single row of data into teradata database. please give me the process.

3 Answers  


What do you mean by teradata intelliflex?

0 Answers  


What is the purpose of upsert command?

0 Answers  


What is meant by a Channel Driver?

0 Answers  


how do you handle ET and UV errors ?

2 Answers  


i have a table like sales....the field are Prodid Jan(jam month sales)Feb March 1 20 76 50 2 30 94 40 3 40 90 30 4 70 20 30 5 23 40 40 6 85 30 55 7 84 20 65 8 10 93 40 9 57 30 30 10 38 83 40 11 35 39 90 12 83 89 50 Now the Question is i want get the max sales of 12 products from the months.hint:for eg I WANT GET 89 for product12... Can any one help me

8 Answers   Satyam,


How do you define Teradata?

0 Answers  


Categories