select count(0) from (select distinct customer_id from t_tran) t
select count(0) from (select distinct customer_id from t_tran) t
SELECT tp.* FROM t_permission tp LEFT JOIN t_role_permission trp ON tp.`id` = trp.`permission_id` LEFT JOIN t_role tr ON tr.`id` = trp.`role_id` LEFT JOIN t_user_role tur ON tur.`role_id` = tr.`id` WHERE tp.type = 'button' && tur.`user_id` = 2
SELECT
tp.*
FROM
t_permission tp
LEFT JOIN t_role_permission trp
ON tp.`id` = trp.`permission_id`
LEFT JOIN t_role tr
ON tr.`id` = trp.`role_id`
LEFT JOIN t_user_role tur
ON tur.`role_id` = tr.`id`
WHERE
tp.type = 'button' &&
tur.`user_id` = 2
select count(0) from (select distinct customer_id from t_tran where stage = 42) t
select count(0) from (select distinct customer_id from t_tran where stage = 42) t