I need to find the total number of orders placed by the client, but also find the top product in one request. For example, in the following structure
CREATE TABLE
I came up with a request,
SELECT * FROM
But this does not give me the result that I am looking for, because Paul gives me the correct ProductId, but only the account of this product.
I want the request to be returned
CustId | CustName | ProductId | TotalQty --------+---------------+---------------+------------ 1 | Paul | 1 | 3 2 | F | 1 | 1 3 | Francis | NULL | NULL
sql sql-server
Paul francis
source share