Saturday, 15 June 2013

oracle - Trying to select all records where two fields are distinct (but the rest don't have to be) -


I have 14 columns in a table that. These columns, color, type, feet, date, are counting etc. What I need most recently to the selection all the different records of the ID and type of date. So, for example ...

color ------ type ----------- date

red ------- - Work ----------- 01/01/01

Red --------- Game ---------- 02/02 / 02

Red --------- Play ---------- 03/03/03

In this case, I would go back to Red want to work, 01/01/01 and red, sports 3/3/03 hope that it makes sense, I have to choose different combinations of unique and individual and group to choose from by , And I'm not able to do anything.

The SQL statement I'm trying:

  select specific chock_id, roll_type, Max (chock_service_dt), chock_id_dt, chock_seq_num, chock_service_cmnt, total_rolled_lineal_ft, total_rolled_tons, chock_usage_cnt , chock_insert_dt, record_modify_dt, next_chock_service_dt_act, previous_alarm_value, chock_id, roll_type, chock_service_dt, chock_id_dt, chock_seq_num, chock_service_cmnt, total_rolled_lineal_ft, total_rolled_tons, chock_usage_cnt, chock_insert_dt, record_modify_dt, next_chock_service_dt_act, previous_alarm_value, upload_complete_yn from tp07_chock_summary_row group upload_complete_yn;   

The image

Here Have a screenshot As I said in the comment below, in rows 2 and 4, I can not record many with the same chock_id and roll_type.

Given your new requirements, which you did not initially understand, should do this: / p>

  select chock_id, roll_type, chock_service_dt, chock_id_dt, chock_seq_num, chock_service_cmnt, total_rolled_lineal_ft, total_rolled_tons, chock_usage_cnt, chock_insert_dt, record_modify_dt, next_chock_service_dt_act, previous_alarm_value, the (chock_id selection upload_complete_yn, roll_type, chock_service_dt, chock_id_dt, chock_seq_num , Chock_service_cmnt, total_rolled_line, total_rolled_tons, chock_usert_dt, chock_usert_dt, chock_inservice_dt, next_chock_service_dt_act, previous_alarm_value, upload_complete_yn, row_number () more than (split by chock_id, roll-type commands by chalk_service_dt desc Sh) rn tp07_chock_summary_row) where rn = 1    

No comments:

Post a Comment