Multiple NOT distinct

后端 未结 4 1650
甜味超标
甜味超标 2020-12-10 12:40

I\'ve got an MS access database and I would need to create an SQL query that allows me to select all the not distinct entries in one column while still keeping all the value

相关标签:
4条回答
  • 2020-12-10 13:34

    Another way of returning the results you want would be this:

    select *
    from
        my_table
    where 
        B in 
        (select B from my_table group by B having count(*) > 1)
    
    0 讨论(0)
  • 2020-12-10 13:38
    Select B, C
    From Table
    Where B In
        (Select B From Table
         Group By B
         Having Count(*) > 1)
    
    0 讨论(0)
  • 2020-12-10 13:39
    select 
      * 
    from 
      my_table t1, 
      my_table t2
    where 
      t1.B = t2.B
    and
      t1.C != t2.C
    
    -- apparently you need to use <> instead of != in Access
    -- Thanks, Dave!
    

    Something like that?

    0 讨论(0)
  • 2020-12-10 13:42

    join the unique values of B you determined with group by b and count > 1 back to the original table to retrieve the C values from the table.

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