7 kyu
Loan Eligibility: part 1
302bornForThis
Description:
We have two tables: customers and loans.
customers
table:
id
(integer): The primary key for the table.age
(integer): The age of the customer.
loans
table:
id
(integer): The primary key for the table.customer_id
(integer): A foreign key referencing id in the customers table.loan_status
(string): The status of the loan, either 'paid' or 'unpaid'.loan_amount
(float): The amount of the loan.
Write a SQL query that returns a list of all customers who have IDs between 1 and 10. For each customer, the query should return their ID (as customer_id) and their loan eligibility based on the following criteria:
- If the customer is 18 to 65 years old (inclusive) and all their loans are paid or they don't have any loans, they should be considered eligible for a loan, and the query should return 'loan can be given'.
- Otherwise, the query should return 'loan cannot be given'.
The results should be sorted by customer_id
in descending order.
GLHF!
Desired Output
The desired output should look like this:
customer_id | loan_eligibility |
---|---|
10 | loan can be given |
9 | loan can be given |
8 | loan cannot be given |
SQL
Databases
Similar Kata:
Stats:
Created | Jun 27, 2023 |
Published | Jun 28, 2023 |
Warriors Trained | 640 |
Total Skips | 69 |
Total Code Submissions | 2070 |
Total Times Completed | 302 |
SQL Completions | 302 |
Total Stars | 13 |
% of votes with a positive feedback rating | 88% of 43 |
Total "Very Satisfied" Votes | 36 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 6 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |