Recurring SQL fields in one field, condition



  • A table

    Id | Date | Title      | Unique Id
    

    1 2020 some title 1
    2 2021 some title 2
    2 2020 some title 3

    All ID repeat lines should be merged into one (the only date known to be different), with the date to be made (firstDate - secondDate). For example, the result should be:

    Id | Date        | Title      | Unique Id

    1 2020 some title 1
    2 2020-2021 some title 2



  • I helped.

    STRING_AGG(Date, '-')
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2