Answer the question
In order to leave comments, you need to log in
How to change the data in a column by the largest value?
I'm learning sql, I can't complete the task.
I have a table:
|id | quarter | latest_vizit_date |
=====================================================================
|1 | 1 | 2019-03-28 |
|1 | 2 | 2021-05-19 |
|1 | 3 | 2018-09-25 |
|1 | 4 | 2018-12-27 |
|2 | 1 | 2021-03-18 |
|2 | 2 | 2021-06-03 |
|2 | 3 | 2020-09-03 |
|2 | 4 | 2020-12-10 |
|id | quarter | latest_vizit_date |
=====================================================================
|1 | 1 | 2021-05-19 |
|1 | 2 | 2021-05-19 |
|1 | 3 | 2021-05-19 |
|1 | 4 | 2021-05-19 |
|2 | 1 | 2021-06-03 |
|2 | 2 | 2021-06-03 |
|2 | 3 | 2021-06-03 |
|2 | 4 | 2021-06-03 |
update mytable
set latest_vizit_date = @max_date
@max_date
I don't know how to determine. I tried this: @max_date := max(latest_vizit_date)
- it is searched for the entire column, but I need it to take into account a separate id and within the quarters from 1 to 4.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question