MySQL get first non null value after group by

前端 未结 1 796
自闭症患者
自闭症患者 2021-02-01 14:32

I have a large table with data that is not unique but needs to be. This table is a result of multiple union selects so is not an actual table. I cannot make it an actual table f

1条回答
  •  清酒与你
    2021-02-01 15:15

    Try using MAX, like this:

    SELECT
        email,
        MAX(`name`)
    FROM
    (
        SELECT
            email,
            `name`
        FROM
            multiple_tables_and_unions
    ) AS emails
    
    GROUP BY email
    

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