15,897,334 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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
HarishRao4
24-Nov-17 2:02am
View
Employee_ID Incentive
2 5000
3 1500
4 7000
5 1100
HarishRao4
24-Nov-17 2:01am
View
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
HarishRao4
24-Nov-17 1:54am
View
SELECT TOP (1)
[Department]
,MAX(Salary) AS [Max_Salary]
FROM [tbl_Employee]
GROUP BY [Department]
ORDER BY MAX([Salary]) DESC
HarishRao4
22-Sep-17 8:54am
View
Thanks Mehdi, most of the tables have the default index, and a few don't as allowing duplicate entries are a mandate
Show More