selectcount(*) as aggregate from `videos` where `videos`.`category_id` =504and `videos`.`category_id` isnotnulland `videos`.`deleted_at` isnullandexists (select*from `users` where `videos`.`user_id` = `users`.`id`) and `approved` =1and (`privacy` =0or `privacy` =2)