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
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 |
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 |
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 |
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 |
Can we load a Multi set table using MLOAD?
Is PK concept available in Teradata. If it is how can we create Primary Key for a table in TD
what is use of fload loading into set table?
How to explain project Architecture and flow in teradata interviews?Can please anyone help on this? Am new to teradata.
0 Answers Infosys, Wells Fargo,
What are the available primary index types in teradata.
Give some points about Teradata Viewpoint ?
write a query following data. 123.45 is input.write a query after decimal (ex:.45) load into database ?how it possible?
Describe primary index in teradata. And what are the available primary index types?
can I use “drop” statement in the utility “fload”?
2 Answers Accenture, CTS, NTT Data,
How is MLOAD Client System restarted after execution?
whether Nulls will be counted while doing average? example: we have table column A with following values A -- 5 Null 8 3 Now what is the average of A?
What is spool space? Why do you get spool space errors?