This gives an error:
SELECT
customerName, customerNumber, SUM(amount)
FROM
customers
LEFT JOIN
payments USING (customerNumber)
GROUP BY customers.customerName
ORDER BY customerName;
BUT 'GROUP BY customers.customerNumber' gives the correct result.
NOTE: 'customerNumber' is present in both the tables but 'customerName' is not.
Columns of table 'customers':
customerNumber int(11) **PK**
customerName varchar(50)
contactLastName varchar(50)
contactFirstName varchar(50)
Columns of table 'payments':
customerNumber int(11) **PK**
checkNumber varchar(50) **PK**
paymentDate date
amount decimal(10,2)
Is this a constraint that we can GROUP BY column which is present in both the tables in case of JOIN?