Using the distinct function in SQL

前端 未结 18 912
無奈伤痛
無奈伤痛 2021-02-06 16:55

I have a SQL query I am running. What I was wanting to know is that is there a way of selecting the rows in a table where the value in on one of those columns is distinct? When

18条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 17:47

    Noone seems to understand what you want. I will take another guess.

    Select * from tbl
    Where ColA in (Select ColA from tbl Group by ColA Having Count(ColA) = 1)
    

    This will return all data from rows where ColA is unique -i.e. there isn't another row with the same ColA value. Of course, that means zero rows from the sample data you provided.

提交回复
热议问题