Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1077791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:37:43+00:00 2026-05-16T21:37:43+00:00

Suppose i have two tables declare @emp table ( EmpID int, EmpName varchar(10) )

  • 0

Suppose i have two tables

declare @emp table
(
  EmpID int,
  EmpName varchar(10)

)

declare @Remu table
(
   EmpID int,
   Sal Decimal(10,2),
   PaidYear varchar(10)
)

I want maximum salary grouped on PaidYear (With Ties)

Expected OUTPUT

EmpID EmpName PaidYear Sal 
1     Jon     2001     2000
2     Smith   2001     2000

3     Nash   2003      4000     
4     Hoge   2005      5000
5     Peter  2005      5000

I have an issue when using Join

select e.EmpID,e.EmpName,r.Sal,r.PaidYear from @emp e
inner join
(select max(Sal) as Sal,PaidYear from @Remu group by PaidYear)r
on e.EmpID=???

when i select EmpID in

select max(Sal) as Sal,PaidYear from @Remu group by PaidYear

i have to Group by PaidYear and EmpID,which won’t give the desired result as i expected.

How to solve this.I want a query which should be compatible with SQL Server 2000.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:37:43+00:00Added an answer on May 16, 2026 at 9:37 pm
    select e.EmpID,e.EmpName,r.Sal,r.PaidYear
    from @emp e inner join @Remu r on e.EmpId = r.EmpId
    where r.sal in (select max(sal) from @remu group by paidyear)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two tables 1st table emp EmpID | EmpName|xyz...coloums 1. | Hrishi
Suppose I have two tables, - emp(empId number(1),empName varchar2(50)) and - manager(manId number(5),managerName varchar2(100))
Suppose you have two tables: Musicians musicianID (primary key, int) name (varchar) instrument (varchar)
Suppose I have the following two tables in my MySQL database: Table 1:: EMP:
Suppose we have two tables Foo and Bar. I have an association table Foo_Bar
Suppose you have two tables in PostgreSQL. Table A has field x , which
Suppose I have two tables, table A and table B, and that table A
Suppose I have a table whose function is specifically to link two other tables
Suppose I have two tables: Table A has information about the stock holdings of
Suppose we have a PostgreSQL database with two tables A, B. table A columns:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.