human
Schema:
Customers (Customer_ID, Customer_Details)
Customer_Policies (Policy_ID, Customer_ID, Policy_Type_Code, Start_Date, End_Date)
Claims (Claim_ID, Policy_ID, Date_Claim_Made, Date_Claim_Settled, Amount_Claimed, Amount_Settled)
Settlements (Settlement_ID, Claim_ID, Date_Claim_Made, Date_Claim_Settled, Amount_Claimed, Amount_Settled, Customer_Policy_ID)
Payments (Payment_ID, Settlement_ID, Payment_Method_Code, Date_Payment_Made, Amount_Payment)
Please answer with SQL.
assistant
Sure, I understand.
human
Which Payments were processed with Visa? List the payment Id, the date and the amount.
assistant
SELECT Payment_ID , Date_Payment_Made , Amount_Payment FROM Payments WHERE Payment_Method_Code = 'Visa'
human
List the method, date and amount of all the payments, in ascending order of date.
assistant
SELECT Payment_Method_Code , Date_Payment_Made , Amount_Payment FROM Payments ORDER BY Date_Payment_Made ASC
human
Find the total claimed amount of all the claims.
assistant
SELECT sum(Amount_Claimed) FROM Claims
human
What is the total amount of settlement made for all the settlements?
assistant
SELECT sum(Amount_Settled) FROM Settlements
human
With which kind of payment method were the least number of payments processed?
assistant
SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY count(*) ASC LIMIT 1
human
What is the total amount of payment?
assistant
SELECT SUM( Amount_Payment ) FROM Payments ;