by walking against super small detail, I need to sort by number of unpaid bills and not by total number of bills, so I was in my initial request "invoicepayee! = 1"
here's what I now :
PHP Code:
SELECT c.id, c.field1, c.field2, count(DISTINCT f.id) AS nbinvoices
FROM clients c LEFT JOIN invoices f ON c.id=f.clientid
GROUP BY c.id
ORDER BY nbinvoices DESC $pagination
what would be nice is being able to do something like that :
PHP Code:
SELECT c.id, c.field1, c.field2, count(DISTINCT f.invoicepayee != 1) AS nbinvoices
FROM clients c LEFT JOIN invoices f ON c.id=f.clientid
GROUP BY c.id
ORDER BY nbinvoices DESC $pagination
but it does not, of course. An idea on how to proceed ?
MERCI INFINIMENT VOUS ÊTES MON AMOUR DE TOUS LES JOURS
Bookmarks