Ok, I have two Queries, the first one I ask for the names of the clients and I order them alphabetically:
SELECT Firstname,
Lastname
FROM customers
ORDER BY Firstname
In the second I request the total of purchases:
Select Customerid, Sum (Total) As Total
From invoices
Group by CustomerId
My goal is to get a table where instead of the CustomerId appearing, I can get FirstName and LastName.
According to me it would have to be something like this:
SELECT Firstname,
Lastname
(
Select Customerid, Sum (Total) As Total
From invoices
Group by CustomerId
) As Total
FROM customers
ORDER BY Firstname
But it does not give me any results so I ask for your help.
Thank you!