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 7973077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:00:50+00:00 2026-06-04T08:00:50+00:00

I am trying to work this solution on how to collapse the records based

  • 0

I am trying to work this solution on how to collapse the records based on a value..

Table 1(Input)

 Emp_ID Start_Date  End_Date    Rating  Department  Salary
2000    01012011    12312011    A   HR          10000
2000    01012012    12319999    A   HR          20000
3000    01012011    12312011    B   Operations  50000
3000    01012012    12312012    B   Operations  60000
3000    01012013    12319999    C   Operations  70000

Table 2(Output)

 Emp_ID Start_Date  End_Date    Rating  Department
2000    01012011    12319999    A   HR
3000    01012011    12312012    B   Operations
3000    01012013    12319999    C   Operations

Database is oracle. I just need some start on how to solve this problem so that i can work on it..

Thanks in Advance..

EDIT: Assuming that Table 1 & Table 2 has EMP_NAME column. But i am not able to load this column in table2 as group by wont let me do that..(I am talking abt the soln given by Pablo Santa Cruz)

Any solutions on this..

EDIT: Edited the table structure agan..sorry for confusion

  • 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-06-04T08:00:51+00:00Added an answer on June 4, 2026 at 8:00 am

    Try this:

    select emp_id, rating, min(start_date), max(end_date)
      from table_1
     group by emp_id, rating
    

    If you need to actually store the values on table_2 table, start the previous SQL statement with create table table_2 as.

    Considering what you’ve comment, you can do:

    create table table_2 as
    select emp_id, rating, min(start_date), max(end_date), 
           'EMP_DEPT_INFO' as emp_deparment
      from table_1
     group by emp_id, rating
    

    Other possibility might be creating the table first, and then doing an alter table to include the new column.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I been trying to work this out but unable too. I have a
i am trying to work this out is the simplest way, i am a
I'm trying to work on this website wherein I need to filter the data
I am trying to detetct/work around this bug in RSS elements. That means I
I'm trying for a while to work this out with no success so far
I ask this because I am currently trying to work out my own technique,
I am trying to work out the best way of doing this but not
I am trying to get nivoSlider to work on this site http://fritech.co.uk/ where it
I'm trying to work out what regular expression I would need to change this
I'm trying to work with EF CodeFirst under Oracle with ODP.net. This is my

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.