Click here to Skip to main content
15,897,334 members

Comments by HarishRao4 (Top 9 by date)

HarishRao4 24-Nov-17 4:37am View    
I am able to achieve with the below 2 queries, but I am looking for a single query to do the work:

select department, max(incentive_amount) as incentive_amount into DeptIncent
from tbl_employee
inner join tbl_incentives on employee_id = employee_ref_id
Group by department


select top 1 department, incentive_amount from DeptIncent order by incentive_amount desc
HarishRao4 24-Nov-17 4:35am View    
I am able to achieve it with the below 2 queries, but what I need is a single query:

select department, max(incentive_amount) as incentive_amount into DeptIncent
from tbl_employee
inner join tbl_incentives on employee_id = employee_ref_id
Group by department

select top 1 department, incentive_amount from DeptIncent order by incentive_amount desc
HarishRao4 24-Nov-17 2:22am View    
Thanks so much, but I was looking for Department and Incentive Amount
HarishRao4 24-Nov-17 2:04am View    
tbl_Employee
Employee_ID Employee_Name Department Salary
1 Harish Support 15000
2 Sudhakar Support 25000
3 Lekhana SimDoc 14000
4 Kishor LMS 45000
5 Pranav SimDoc 13000

tbl_Incentives
Employee_ID Incentive
2 5000
3 1500
4 7000
5 1100
HarishRao4 24-Nov-17 2:02am View    
One is an Employee and the other is an Incentives table