SELECT Client Name, Count Invoices?

Let’s say I want to get a list of client Names, and a count of their invoices via SQL in 4D.

I think I should be able to do this:

SELECT
Name,
( SELECT COUNT (*) FROM Invoices where Invoices.Client_ID = Client.id)
FROM Client

But this doesn’t work.
What’s the proper sql to do this?

An old answer:

http://forums.4d.com/Post/FR/3953202/1/3953203#3967527http://forums.4d.com/Post/FR/3953202/1/3953203#3967527>

to say no.

I have this example working, but I get client Primary Keys in 1st column, not the names.
<code 4D>
ARRAY LONGINT($clientPK_al;0)
ARRAY LONGINT($count_al;0)
Begin SQL
SELECT FK_client , COUNT(FK_client)
FROM Invoice
GROUP BY FK_client
INTO :$clientPK_al, :$count_al;
End SQL
</code 4D>

with the names:
<code 4D>
Début SQL
SELECT COUNT(Invoice.FK_Client) , Client.name
FROM Invoice
INNER JOIN Client ON Client.PK=Invoice.FK_Client
GROUP BY Client.name
INTO :$count_al, :$name_at ;
Fin SQL
</code 4D>

Try this.

SELECT c.Name, Count(*)
FROM Client AS c
LEFT OUTER JOIN Invoices AS i ON i.Client_ID = c.ID
GROUP BY 1