Back to questions

ApplePay Volume Visa SQL Interview Question

ApplePay Volume

Visa SQL Interview Question

Visa is analysing its partnership with ApplyPay. Calculate the total transaction volume for each merchant where the transaction was performed via ApplePay.

Output the merchant ID and the total transactions. For merchants with no ApplePay transactions, output their total transaction volume as 0. Display the result in descending order of the transaction volume.

Tip: You might want to check the spelling of the payment methods... just sayin' 👀

Table:

Column NameType
merchant_idinteger
transaction_amountinteger
payment_methodvarchar

Example Input:

merchant_idtransaction_amountpayment_method
1600Contactless Chip
1850apple pay
1500Apple Pay
2560Magstripe
2400Samsung Pay
41200apple pay

Example Output:

merchant_idtotal_transaction
11350
41200
20

Explanation

Merchant 1 has made two ApplePay purchases totalling $1,350, Merchant 4 has completed one ApplePay transaction costing $1,200, and Merchant 2 has not completed any ApplePay transactions.

The dataset you are querying against may have different input & output - this is just an example!

Input

Output