There will be no complex stored procedures available anywhere if you look for them online since complexity arises when you have a requirement that leads to it.
A sample database schema for information on mobile calls, their owners, mobile recharges, consumption, etc. is attached. The schema is created based on the following requirement.
- Customers exist, and each customer may have several phone numbers.
- The customer recharges each phone number to keep the credit amount in tact.
- Even if there isn’t enough money in the account, calls can still be placed.
- You can activate or deactivate phone numbers.
- Depending on the occasion, different tariffs (price per call) apply. For instance, the price of a call varies depending on whether it is made during the day or at night. The price per call varies on weekends. Prices fluctuate on holidays.
Now, write a script or a stored procedure to get the following information.
- The call’s duration is unspecified. As a result, you must recognize it.
- Since the actual call cost is not calculated anywhere in the database, you must calculate it.
- Based on the call rate specified in the static table, the call cost must be accurately determined.
- All the above-said requirements must be accomplished in a single execution.
One comment