0

我有一张像这样的桌子:

ID_USER USERNAME_USER REF_USER STATUS_AKTIF
1       a                      aktif
2       b             a        tidak
3       c             a        aktif
4       d             b        aktif
5       e             a        aktif

我使用这个代码:

select REF_USER, count(distinct USERNAME_USER) as TOTAL from TABLE where (REF_USER IS NOT NULL AND REF_USER!="" AND STATUS_AKTIF='aktif') group by REF_USER

但我只得到:

REF_USER TOTAL
a        2
b        1

我怎样才能删除 b ?因为用户 b STATUS_AKTIF 是 tidak

4

1 回答 1

0

只需添加一个组

SELECT count(*) as total, username_user FROM table 
WHERE (REF_USER IS NOT NULL AND REF_USER!="" AND STATUS_AKTIF='aktif') 
GROUP BY username_user 
于 2015-03-13T10:18:14.587 回答