For this Question: Write a query that joins this submit event table to the loan table and returns the total loan balance on each user's most recent refinance submission. Return all users and the loan balance for each of them.DataFrame/SQL Table with the following schema
<schema>[{'name': 'Loans', 'columns': [{'name': 'id', 'type': 'int64'}, {'name': 'user_id', 'type': 'int64'}, {'name': 'created_at', 'type': 'datetime64[ns]'}, {'name': 'status', 'type': 'object'}, {'name': 'type', 'type': 'object'}]}, {'name': 'submissions', 'Columns': [{'name': 'id', 'type': 'int64'}, {'name': 'balance', 'type': 'float64'}, {'name': 'interest_rate', 'type': 'float64'}, {'name': 'rate_type', 'type': 'object'}, {'name': 'loan_id', 'type': 'int64'}]}]</schema>Each row in new line and each value of a row separated by a |, i. e.
0|1|2
1|2|3
2|3|4-, I have written this Solution Code: SELECT l.user_id,
       SUM (balance)
FROM
  (SELECT DISTINCT id, user_id, created_at,
                   max(created_at) OVER (PARTITION BY user_id,
                                                      TYPE) most_recent
   FROM loans
   WHERE TYPE = 'Refinance') l
INNER JOIN submissions s ON l.id = s.loan_id
WHERE most_recent = created_at
GROUP BY l.user_id, In this Programming Language: SQL, Now tell me if this Code is compilable or not?