Help optimize queries

Help optimize queries to one or two. thanks

SELECT count(id) as count_refferers FROM users WHERE ref = '".$CURUSER['id']."'

SELECT count(id) as count_ref_money, sum(count_games) as count_games FROM users WHERE ref = '".$CURUSER['id']."' AND total_mu > '0'

and

SELECT sum(amount) as total_amount FROM payments_partners WHERE to_userid = '".$CURUSER['id']."' AND hold = 'yes' AND payout = 'no'

SELECT sum(amount) as total_amount FROM payments_partners WHERE to_userid = '".$CURUSER['id']."' AND hold = 'no' AND payout = 'no'

SELECT sum(amount) as total_amount FROM payments_partners WHERE to_userid = '".$CURUSER['id']."' AND hold = 'no' AND payout = 'yes'

okay, two –

SELECT count(id) as count_refferers , count(case when total_mu > '0' then id end) as count_ref_money , sum(case when total_mu > '0' then count_games end) as count_games FROM users WHERE ref = '".$CURUSER['id']."'

SELECT sum(CASE WHEN hold = 'yes' AND payout = 'no' THEN amount END) as total_amount_yes_no , sum(CASE WHEN hold = 'no' AND payout = 'no' THEN amount END) as total_amount_no_no , sum(CASE WHEN hold = 'no' AND payout = 'yes' THEN amount END) as total_amount_no_yes FROM payments_partners WHERE to_userid = '".$CURUSER['id']."'

1 Like

thanks you very much!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.