I have a table Customers with 2 fields (Id, FullName) and a table Payments with two fields (CustId, Amount). In Payments a given customer may occurr in more records if he made more than 1 payment.
The following query extracts the names of the customers who made at least 1 payment which was greater than 1000:
SELECT Customers.FullName FROM Customers
WHERE Customers.Id IN
(SELECT Payments.CustId FROM Payments
WHERE Payments.Amount > 1000)
;
So i get my list of customers names, with 1 column, without duplicates.
I would like to get one more column, showing right the Amount which made the subquery condition true for that customer.
I don' t care whether for a given customer there it was more than 1 record in Payments having an Amount > 1000: i just want to show the one which made the subquery condition true.
How do i do that ?
Thanks in advance.
The following query extracts the names of the customers who made at least 1 payment which was greater than 1000:
SELECT Customers.FullName FROM Customers
WHERE Customers.Id IN
(SELECT Payments.CustId FROM Payments
WHERE Payments.Amount > 1000)
;
So i get my list of customers names, with 1 column, without duplicates.
I would like to get one more column, showing right the Amount which made the subquery condition true for that customer.
I don' t care whether for a given customer there it was more than 1 record in Payments having an Amount > 1000: i just want to show the one which made the subquery condition true.
How do i do that ?
Thanks in advance.