0
I have the following structure:
ID  |   PROMESSA    |   VENCIMENTO  
1   |   2019-01-04  |   2019-10-08
2   |   2019-01-03  |   2019-10-07
3   |   2019-01-02  |   2019-10-06
4   |   NULL        |   2019-10-05
5   |   NULL        |   2019-10-04
6   |   NULL        |   2019-10-03
7   |   NULL        |   2019-10-02
8   |   NULL        |   2019-10-01
I would like to select the records by sorting through the field PROMESSA growing, then through the countryside VENCIMENTO crescent.
The two fields are in format date.
I tried so : ORDER BY IF(PROMESSA IS NULL, 1, 0), PROMESSA ASC, VENCIMENTO ASC;
Expected result:
    ID  |   PROMESSA    |   VENCIMENTO
    3   |   2019-01-02  |   2019-10-06
    2   |   2019-01-03  |   2019-10-07
    1   |   2019-01-04  |   2019-10-08
    8   |   NULL        |   2019-10-01
    7   |   NULL        |   2019-10-02
    6   |   NULL        |   2019-10-03
    5   |   NULL        |   2019-10-04
    4   |   NULL        |   2019-10-05
Any suggestions?
Have you tried
ORDER BY COALESCE(PROMESSA, VENCIMENTO)?– Sorack
If the two columns have a valid date, the previous suggestion does not guarantee the requirement of the question: "I would like to select the records by sorting by the PROMISE ascending field, then by the INCREASING MATURITY field"
– bruno