nitaish Posted August 25, 2020 Share Posted August 25, 2020 I want to export list of clients in whmcs who has more than 2 invoices unpaid. Can anyone help me with the SQL query? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 25, 2020 Share Posted August 25, 2020 (edited) I would have thought the following should return what you want... SELECT tblclients.* FROM tblinvoices JOIN tblclients ON tblinvoices.userid = tblclients.id WHERE tblinvoices.`status` = 'Unpaid' GROUP BY tblinvoices.userid HAVING count(tblinvoices.userid) >= 2 i'm not sure what you want in terms of clients details, so i'm returning everything! you can tweak the select to specify which columns you want to return in the results. Edited August 25, 2020 by brian! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.