Skip to main content
added 10 characters in body
Source Link
Andronicus
  • 26.2k
  • 18
  • 55
  • 92

I have a table like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 1 2 | 1 1 | 1 2 | 2 2 | 2 1 | 2 

I need to get only rows on max(treatment)max(treatment) like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 2 2 | 2 

The patient_idpatient_id 1 the max(treatment)max(treatment) is 3 The patient_idpatient_id 2 the max(treatment)max(treatment) is 2

I have a table like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 1 2 | 1 1 | 1 2 | 2 2 | 2 1 | 2 

I need to get only rows on max(treatment) like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 2 2 | 2 

The patient_id 1 the max(treatment) is 3 The patient_id 2 the max(treatment) is 2

I have a table like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 1 2 | 1 1 | 1 2 | 2 2 | 2 1 | 2 

I need to get only rows on max(treatment) like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 2 2 | 2 

The patient_id 1 the max(treatment) is 3 The patient_id 2 the max(treatment) is 2

edited tags
Link
user330315
user330315
Source Link
Italo Rodrigo
  • 1.8k
  • 5
  • 20
  • 42

Get only rows where data is the max value

I have a table like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 1 2 | 1 1 | 1 2 | 2 2 | 2 1 | 2 

I need to get only rows on max(treatment) like this:

treatment | patient_id 3 | 1 3 | 1 3 | 1 2 | 2 2 | 2 

The patient_id 1 the max(treatment) is 3 The patient_id 2 the max(treatment) is 2