Filter Results in SQL

后端 未结 4 1477
臣服心动
臣服心动 2020-12-04 04:31

Suppose I have a table

  id            value
------        ---------
  10              123
  10              422
  11              441
  11              986
         


        
4条回答
  •  忘掉有多难
    2020-12-04 05:02

    With mysql 8+ or mariadb 10.2+, you would use the count window function:

    select id, value
    from (
        select id, value, count(id) over (partition by id) as num_values
        from sometable
    ) foo
    where num_values > 1;
    

提交回复
热议问题