Search code examples
mysqlcountdistinct

mysql count unique row values


TABLE quotation

id  clientid
1   25
2   25
3   25
4   25
5   26

How can I query how many different clients exist in TABLE quotation? I don't want duplicate entries to be counted more than once.

I need the answer to be 2, in 1 row, because the only non-duplicated entries are (25, 26).


Solution

  • select count(distinct clientid) from quotation
    

    read more