Final answer:
To solve this problem, you can create a stored function in a database that takes two inputs: year and sid. The function should have several conditions to handle different scenarios.
Step-by-step explanation:
To solve this problem, you can create a stored function in a database that takes two inputs: year and sid. The function should have several conditions to handle different scenarios:
- If the year is empty or null, return the error message 'Please input a valid year.'
- If the sid is empty or null, return the error message 'Please input a valid student id.'
- If both inputs are valid, retrieve the total payment amount for the given student ID and year from the database.
- If the input sid is '*', retrieve the total payment amount for all students for the input year.
- If the input year is '*', retrieve the total payment amount for the given student ID for all years.
- If no record is found for the given year and sid, return the message 'No record found for student id: zzzz at year: yyyy.'
Make sure to refer to the Students, Courses, and Students Courses tables for the required data. Assume each credit is $100.