Write a soL statement that will pull balance and last payment amount by account
ID: 3909657 • Letter: W
Question
Write a soL statement that will pull balance and last payment amount by account for the previous 7 days of data. Do not hard-code your dates 2 Write a query to pull the total payments and average payment amount received in January 2001 3 Write a query to pull each account's most recent balance. Add an additional column that marks the account as Paid Off is balance is zero 4Using temp tables, build a SQL statement that will show the final balance of each account, by month 5 Write a SQL statement to show how much principal each customer paid in their last payment. If data is unavailable, simply return O 7For the purpose of this example, "Today" is 1/15 2001 Table Name: dbo.Balances Account Number AsOfDate Table Name Account Number Last Paid Last Paid Amount AsOfDate 12/31/00 12/30/16 2/31/00 5000.00 1/1/01 12/30/16 /2/01 2/30/16 /3/01 2/30/16 1/4/01 100.00 1100.00 1100.00 1100.00 1100.00 1100.00 1100.00 1100.00 1100.00 1100.00 100.00 4200.00 1/6/01 1/4/01 1/7/01 4200.00 4200.00 4200.00 /10/014200.00 1/11/01 4200.00 1/12/01 4200.00 /13/01 4200.00 1/7/01 1/4/01 1/8/01 1/9/01 1/10/01 1/11/01 1/12/01 1/13/01 1/14/01 12/31/00 12/15/00 1/4/01 1/4/01 1/4/01 1/4/01 114/01 4200 2/31/00 10000.00 /1/0110000.00 12/15/00 2/01 12/15/00 1/3/01 12/15/00 /4/01 10000.00 /5/0110000.00 1/6/01 10000.00 7/01 10000.00 1/8/01 10000.00 /9/0110000.00 /10/01 10000.00 1/11/01 10000.00 1/12/01 10000.00 1/13/01 10000.00 1/14/01 10000.00 4/01 12/15/00 1/5/01 12/15/00 1/6/0 12/15/00 /7/0112/15/00 /8/0112/15/00 /9/0112/15/00 1/10/01 12/15/00 /11/01 1/11/01 112/0 1/11/01 /13/011/11/01 14/011/11/0 37Explanation / Answer
Solution:
The SQL statement is given below:
SELECT SUM(Last Paid Amount), AVG(Last Paid Amount) FROM dbo.Payments WHERE Last Paid = "January 2001".
Explanation:
The SUM() and AVG() aggregate function is used here to find the total and average of the of the payments.
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.