|
question;query;db_id
|
|
What are the primary contract ID, day name, and product family code for transactions where the transaction ID is either 80537 or 66505, or the transaction is not marked as fraudulent, grouped by the primary contract ID?;"SELECT Transactions.primary_contract_id, Time.day_name, Transactions.product_family_code FROM Transactions INNER JOIN Time ON Transactions.timestamp_id = Time.timestamp_id WHERE transaction_id IN (80537, 66505) OR is_fraudulent = ""No"" GROUP BY primary_contract_id";transactions_db
|
|
Fetch all the accounts;SELECT * FROM Accounts;loan_db
|
|
What are the distinct currencies in the Transactions table?;SELECT DISTINCT amount_currency FROM Transactions ;transactions_db
|
|
Retrieve the first name and last name of the client with the higher account balance;SELECT first_name, last_name, MAX(balance) FROM Accounts JOIN Clients ON Accounts.client_id = Clients.client_id;loan_db
|
|
What is the sum of transaction amounts of the client with id 75369 on month number 11?;"SELECT Transactions.client_id, Time.month_number, SUM(Transactions.transaction_amount) FROM Time JOIN Transactions ON Time.timestamp_id = Transactions.timestamp_id WHERE Transactions.client_id =75369 and Time.month_number = 11;";transactions_db
|
|
"Fetch the loan_id, the budget, and the duration of the loans of the clients in ""Madrid"" or ""Barcelona"" city ";"SELECT loan_id, budget, duration FROM Loans JOIN Clients ON Loans.client_id = Clients.client_id WHERE city in (""Madrid"",""Barcelona"")";loan_db
|
|
Get the sum of the transaction amounts for each currency.;"SELECT amount_currency, SUM(transaction_amount) FROM Transactions GROUP BY amount_currency;";transactions_db
|
|
Retrieve the count of transactions, along with the product family code, counterparty donor ID, and beneficiary ID, where the timestamp ID is 41332 and the client ID is 32441. Group the results by the product family code.;SELECT Transactions.product_family_code, Source.counterparty_donor_id, COUNT(*), Transactions.beneficiary_id FROM Transactions LEFT JOIN Source ON Transactions.primary_contract_id = Source.primary_contract_id WHERE NOT timestamp_id <> 41332 AND client_id = 32441 GROUP BY product_family_code;transactions_db
|
|
What is the account_id and the client_id of saving accounts with balance bigger than 150000;"SELECT account_id, client_id FROM Accounts WHERE type = ""Saving account"" AND balance > 150000";loan_db
|
|
"How many clients live in ""Dubai"" and born before 2010";"SELECT COUNT(*) FROM Clients WHERE city LIKE ""Dubai"" AND year_of_birth < 2024";loan_db
|
|
Get the transaction id of the largest transaction amount.;"SELECT transaction_id, MAX(transaction_amount) FROM Transactions;";transactions_db
|
|
Find the Client_ID and Transaction_ID of transactions with an amount greater than 100.;"SELECT client_id, transaction_id FROM Transactions WHERE transactions_amount > 100;";transactions_db
|
|
Find the total number of transactions in the Transactions table.;"SELECT COUNT(transaction_id) FROM Transactions;";transactions_db
|
|
Provide the deposits of the account id 15423;SELECT * FROM Deposits WHERE account_id = 15423;loan_db
|
|
"What is the sum of deposits of the account_id 14523 with source as ""cash""";SELECT SUM(amount) FROM Deposits WHERE account_id = 14523 AND source LIKE 'Cash';loan_db
|
|
Find the average transaction amount for each currency.;"SELECT amount_currency, AVG(transaction_amount) FROM Transactions GROUP BY amount_currency;";transactions_db
|
|
List all the loans;SELECT * FROM Loans;loan_db
|
|
Get the bank branch code and country of the beneficiary with beneficiary_id 0129776190.;"SELECT bank_branch_id, country_code FROM Beneficiary WHERE beneficiary_id = 0129776190;";transactions_db
|
|
List the top 3 beneficiaries who have received the highest sum of transaction amount across all transactions.;"SELECT Beneficiary.benificiary_id, SUM(Transactions.transaction_amount) AS TotalAmountReceived FROM Beneficiary JOIN Transactions T ON Beneficiary.beneficiary_id = Transactions.beneficiary_id GROUP BY Beneficiary.beneficiary_id ORDER BY TotalAmountReceived DESC LIMIT 3;";transactions_db
|
|
"What is the first_name and the email of the clients that live in ""New York"" city";"SELECT first_name, email FROM Clients WHERE city = ""New York""";loan_db
|
|
What is the average of transactions amounts?;"SELECT AVG(transaction_amount) FROM Transactions;";transactions_db
|
|
Retrieve all transactions with an amount bigger than 1632 'EUR'.;"SELECT transaction_id, transaction_amount FROM Transactions WHERE transaction_amount > 1632 and amount_currency='EUR';";transactions_db
|
|
List the unique product family codes in the Transactions table.;"SELECT DISTINCT product_family_code FROM Transactions;";transactions_db
|
|
"How many accounts are associated with client with ""Mike"" as a first name or ""Donald"" as a last name";"SELECT COUNT(*) FROM Accounts JOIN Clients ON Accounts.client_id = Clients.client_id WHERE first_name LIKE ""Mike"" or last_name LIKE ""Donald""";loan_db
|
|
List the accounts of the clients born before 1999 grouped by client id;SELECT * FROM Accounts JOIN Clients ON Accounts.client_id = Clients.client_id WHERE year_of_birth < 1999 GROUP BY Clients.client_id;loan_db
|
|
How many banks have a bank branch ID different than 29887?;SELECT COUNT(bank_branch_id) FROM Beneficiary WHERE NOT bank_branch_id <> 29887;transactions_db
|
|
Find the primary contract id for the client with the highest total transaction amount in Euro.;"SELECT Source.primary_contract_id, MAX(Transactions.transaction_amount) FROM Source INNER JOIN Transactions ON Source.client_id = Transactions.client_id WHERE amount_currency = 'EUR';";transactions_db
|
|
"Fetch the account_id and the balance of the saving accounts of the clients placed in ""Marrakech"" city and their balance is bigger than 100000";"SELECT account_id, balance FROM Accounts JOIN Clients ON Accounts.client_id = Clients.client_id WHERE type = ""Saving account"" AND city LIKE ""Marrakech"" AND balance > 100000";loan_db
|
|
"How many current loans are taken by clients in ""Vancouver"" city";"SELECT COUNT(loan_id) FROM Loans JOIN Clients ON Loans.client_id = Clients.client_id WHERE city like ""Vancouver"" and status = ""current""";loan_db
|
|
What is the loan_id and the interest of the loans that have a duration less than 2 years;SELECT loan_id, interest FROM Loans WHERE duration < 2;loan_db
|
|
Retrieve the transaction with timestamp id equal to 1.;"SELECT * FROM Transactions WHERE timestamp_id = 1;";transactions_db
|
|
Get the names of all countries in the Beneficiary table.;"SELECT DISTINCT country_name FROM Beneficiary;";transactions_db
|
|
"List all the loans with status ""current"" and interest bigger than 5 percent";"SELECT * FROM Loans WHERE status = ""current"" AND interest > 5";loan_db
|
|
List the unique country names of beneficiaries.;SELECT DISTINCT country_name FROM Beneficiary ;transactions_db
|
|
List all transactions made to beneficiaries in 'Luxembourg' or 'Germany'.;"SELECT Transactions.transaction_id, Benificiary.country_name FROM Transactions JOIN Beneficiary ON Transactions.beneficiary_id = Beneficiary.beneficiary_id WHERE Benificiary.country_name IN ('Luxembourg', 'Germany');";transactions_db
|
|
List all transactions made to the beneficiary in 'Luxembourg'.;"SELECT Transactions.transaction_id FROM Transactions JOIN Beneficiary ON Transactions.beneficiary_id = Beneficiary.beneficiary_id WHERE Beneficiary.country_name='Luxembourg';";transactions_db
|
|
What is the client id and the balance of deposit accounts or account ids in (10452, 15402, 25648);"SELECT client_id, balance FROM Accounts WHERE type LIKE ""Deposit account"" OR account_id IN (10452, 15402, 25648)";loan_db
|
|
Retrieve the clients who have fraudulent transactions.;"SELECT client_id FROM Transactions WHERE is_fraudulent = 'Yes';";transactions_db
|
|
Retrieve all clients who have a primary_contract_id among (152234, 548887, 454877) in the Source table.;"SELECT client_id, primary_contract_id FROM Source WHERE primary_contract_id in (152234, 548887, 454877);";transactions_db
|
|
What is the total loan budget of clients born before 2000 grouped by year of birth;SELECT SUM(budget), year_of_birth FROM Loans JOIN Clients ON Loans.client_id = Clients.client_id WHERE year_of_birth < 2000 GROUP BY year_of_birth;loan_db
|
|
Find the total number of unique counterparty bank branch id in the Source table.;"SELECT COUNT(DISTINCT counterparty_bank_branch_id) FROM Source;";transactions_db
|
|
Retrieve client ids along with the emails of clients who have neve took a loan;SELECT client_id, email FROM Clients LEFT JOIN Accounts ON Client.client_id = Account.account_id WHERE Account.loan_id = NULL;loan_db
|
|
What is the deposit id and account_id of all deposits;SELECT deposit_id, account_id FROM Deposits;loan_db
|
|
Find the number of beneficiaries in each country from the Beneficiary table ordered by the country name.;"SELECT country_name, COUNT(beneficiary_id) FROM Beneficiary GROUP BY country_name ORDER BY country_name;";transactions_db
|
|
What is the client id and the average amount of deposits of a client with client_id in (145745, 12356, 15246) grouped by client;SELECT client_id, AVG(amount) FROM Deposits JOIN Acconts ON Deposits.account_id = Accounts.account_id WHERE client_id IN (145745, 12356, 15246) GROUP BY client_id;loan_db
|
|
How many deposits for the client id 47586 with a cash source or an amount bigger than 50000;"SELECT COUNT(*) FROM Deposits JOIN Acconts ON Deposits.account_id = Accounts.account_id WHERE source LIKE ""Cash"" OR amount > 50000";loan_db
|
|
What is the deposit id and the source of deposits related to saving accounts;"SELECT deposit_id, source FROM Deposits JOIN Acconts ON Deposits.account_id = Accounts.account_id WHERE Account.type = ""Saving account""";loan_db
|
|
Get the transaction id and Amount of the top 3 largest Euro transactions.;"SELECT transaction_id, transaction_amount FROM Transactions WHERE amount_currency='EUR' ORDER BY transaction_amount ;";transactions_db
|
|
Provide the average balance of the Loan Accounts;"SELECT AVG(balance) FROM Accounts WHERE type LIKE ""Loan account""";loan_db
|
|
How many accounts are associated with client_id 15423;SELECT COUNT(account_id) FROM Accounts WHERE client_id = 15423;loan_db
|
|
What are the loans that have a budget bigger than 100000;SELECT * FROM Loans WHERE budget > 100000;loan_db
|
|
Get the sum of the transaction amount for each client.;"SELECT client_id, SUM(transaction_mount) FROM Transactions GROUP BY client_id;";transactions_db
|
|
"Retrieve the loan id, the interest, and the status of the loans of clients with first names in (""John"", ""Blade"",""Smith"") or duration bigger than 10 years";"SELECT loan_id, interest, status FROM Loans JOIN Clients ON Loans.client_id = Clients.client_id WHERE first_name IN (""John"", ""Blade"",""Smith"") OR duration > 10 ";loan_db
|
|
"List the distinct beneficiary ids that live in ""Belgium"",";"SELECT DISTINCT beneficiary_id FROM Beneficiary WHERE country_name LIKE ""Belgium""";transactions_db
|
|
List all the transactions.;SELECT * FROM Transactions ;transactions_db
|
|
List all transactions made to beneficiaries with a country code 'LUX' with a bank branch id in (1758,1236).;"SELECT Transactions.transaction_id FROM Transactions JOIN Beneficiary ON Transactions.beneficiary_id = Beneficiary.beneficiary_id WHERE Beneficiary.country_code = 'LUX' AND Beneficiary.bank_branch_id IN (1758,1236);";transactions_db
|
|
Provide the deposits of the client id 15243;SELECT * FROM Deposits JOIN Acconts ON Deposits.account_id = Accounts.account_id WHERE client_id = 15243;loan_db
|
|
List all clients who made transactions in 'USD'.;"SELECT DISTINCT Source.client_id FROM Source INNER JOIN Transactions ON Source.client_id = Transactions.client_id WHERE Transactions.amount_currency = 'USD';";transactions_db
|
|
Retrieve the transaction id and the product family code of transactions made on 'Tuesday' on hour number 11 on year 2022.;"SELECT Transactions.transaction_id, Transactions.product_family_code FROM TransactionsINNER JOIN Time ON Transactions.time_stamp_id = Time.time_stamp_id WHERE Time.day_name = 'Tuesday' AND Time.hour_number = 11 AND Time.year = 2022;";transactions_db
|
|
List all transactions made on 'Monday' on week number 43 and have an amount greater than 50.;"SELECT Transactions.transaction_id FROM Transactions JOIN Time ON Transactions.time_stamp_id = Time.time_stamp_id WHERE Time.day_name = 'Monday' AND Transactions.week_number = 43 AND Transactions.transaction_amount > 50;";transactions_db
|
|
What is the number of transactions done each day of the week?;"SELECT Time.day_name, COUNT(Transactions.transaction_id) FROM Time JOIN Transactions ON Time.timestamp_id = Transactions.timestamp_id GROUP BYTime.day_name;";transactions_db
|
|
Provide transaction ID, along with the beneficiary ID and counterparty bank branch ID, for cases marked as fraudulent or belonging to the product family with the code 98827 grouped by the client id? ;"SELECT Transactions.beneficiary_id, Source.counterparty_bank_branch_id, Transactions.transaction_id FROM Transactions LEFT JOIN Source ON Transactions.primary_contract_id = Source.primary_contract_id WHERE is_fraudulent <> ""No"" OR product_family_code = 98827 GROUP BY client_id";transactions_db
|
|
"What is the client_id and the year of birth of the client with email ""John.Smith@cs.ma"" or client_id in (21452, 12365, 45789)";"SELECT client_id, year_of_birth FROM Clients where email LIKE ""John.Smith@cs.ma"" OR client_id IN (21452, 12365, 45789)";loan_db
|
|
Retrieve the counterparty_bank_branch_id from the 'Source' table where the primary_contract_id is 93733 and the counterparty_donor_id is 79707.;SELECT counterparty_bank_branch_id FROM Source WHERE primary_contract_id = 93733 AND counterparty_donor_id = 79707;transactions_db
|
|
Find the fraudulent transactions.;"SELECT transaction_id FROM Transaction WHERE is_fraudulent = 'Yes';";transactions_db
|
|
How many beneficiaries have a country code 'CA' or 'DE' group by country code?;SELECT COUNT(*), country_code FROM Beneficiary WHERE country_code IN ('CA', 'DE') GROUP BY country_code;transactions_db
|
|
Retrieve all transactions made to the beneficiary with beneficiary_id '15154236'.;"SELECT Transactions.transaction_id, Transactions.transaction_amount FROM Transactions JOIN Beneficiary on Transactions.beneficiary_id = Beneficiary.beneficiary_id WHERE beneficiary_id ='15154236';";transactions_db
|
|
How many beneficiaries are in each country?;"SELECT country_name, COUNT(*) FROM Beneficiary GROUP BY country_name;";transactions_db
|
|
Provide the loan_id and the budget for the clients with ids in (11123, 15423, 523648);SELECT loan_id, budget FROM Loans WHERE client_id IN (11123, 15423, 523648);loan_db
|
|
"Provide the deposit_id and the amount of deposits with source in (""Cash"" , ""Transaction"") or amount bigger than 142000";SELECT deposit_id,amount FROM Deposits WHERE source in ('Cash', 'Transaction') OR amount > 142000 ;loan_db
|
|
Provide the first_name and last_name of the client with with client_id equal to 15264;SELECT first_name, last_name FROM Clients WHERE client_id = 15264;loan_db
|
|
Find the total amount of transactions made in 'EUR' currency.;"SELECT SUM(transaction_amount) FROM Transactions WHERE Currency = 'EUR';";transactions_db
|
|
"Provide the loan information of the client with email ""John.Smith@cs.ma""";"SELECT * FROM Loans JOIN Clients ON Loans.client_id = Clients.client_id WHERE email = ""John.Smith@cs.ma""";loan_db
|
|
List all transactions made by clients from branch 'LU01'.;"SELECT Transactions.transaction_id, Transactions.client_id FROM Transactions JOIN Source on Transactions.client_id = Source.client_id WHERE Source.counterparty_bank_branch_id = 'LU01';";transactions_db
|
|
What is the client_id and the email of the client with the minimum balance in a saving account ;"SELECT Clients.client_id, Clients.email, MIN(balance) FROM Accounts JOIN Clients ON Accounts.client_id = Clients.client_id WHERE type = ""Saving account""";loan_db
|
|
How many countries are in the Benefeciary table beside 'England'?;SELECT COUNT(distinct country_code), country_name FROM Beneficiary WHERE country_name <> 'England';transactions_db
|
|
List all the fraudulent transactions.;"SELECT * FROM Transactions WHERE is_fraudulent = ""Yes"";";transactions_db
|
|
Retrieve all the unique clients who have made transactions in both 'EUR' and 'USD'.;"SELECT DISTINCT client_id FROM Transactions WHERE amount_currency IN ('EUR', 'USD');";transactions_db
|
|
Who is the client that made the biggest transaction_amount on the year 2022?;SELECT Transactions.client_id , MAX(Transactions.transaction_amount) FROM Transactions JOIN Time ON Transactions.timestamp_id = Time.timestamp_id WHERE Time.year = 2022;transactions_db
|
|
How many deposits for the account ids in (45781, 24523, 78945);SELECT COUNT(*) FROM Deposits WHERE account_id in (45781, 24523, 78945);loan_db
|
|
Provide the transaction id, along with the transaction amount for transactions done on Mondays.;SELECT Transactions.transaction_id, Transactions.transaction_amount FROM Transactions JOIN Time ON Transactions.timestamp_id = Time.timestamp_id WHERE Time.day_name='Monday';transactions_db
|
|
Retrieve the primary contract id for the client identified by 20001920.;SELECT primary_contract_id FROM Source WHERE client_id = 20001920;transactions_db
|
|
"How many clients live in ""Paris"" and their first names in (""John"", ""Jacob"", ""Youssef"")";"SELECT COUNT(client_id) FROM Clients Where city LIKE ""Paris"" AND first_name IN (""John"", ""Jacob"", ""Youssef"")";loan_db
|
|
Retrieve the sum of transactions amount for each product family.;"SELECT product_family_code, SUM(transaction_amount) FROM Transactions GROUP BY product_family_code;";transactions_db
|
|
List all transactions made by a client with client_id 20001103.;SELECT transaction_id FROM Transactions WHERE client_id = 20001103;transactions_db
|
|
|