SQL How to remove duplicates within select query?

前端 未结 7 762
甜味超标
甜味超标 2021-01-04 07:05

I have a table which looks like that:

\"alt

As You see, there are some date duplicates, so how t

相关标签:
7条回答
  • 2021-01-04 07:34

    There are multiple rows with the same date, but the time is different. Therefore, DISTINCT start_date will not work. What you need is: cast the start_date to a DATE (so the TIME part is gone), and then do a DISTINCT:

    SELECT DISTINCT CAST(start_date AS DATE) FROM table;
    

    Depending on what database you use, the type name for DATE is different.

    0 讨论(0)
提交回复
热议问题