wrong count in query

前端 未结 6 1041
故里飘歌
故里飘歌 2021-01-25 17:05

I have a table whose structure is as follows:

id  int
userid  int
status  enum (\'pending\',\'approved\')
dop     datetime

Data is as:

6条回答
  •  伪装坚强ぢ
    2021-01-25 18:03

    You sould use the COUNT(DISTINCT()) construction, it allow you to count the diferent values not NULL (docu)

    Try this sentence:

    SELECT count( DISTINCT( userid ) )
    FROM t1
    WHERE STATUS = 'pending'
    GROUP BY userid
    

    HTH!

提交回复
热议问题