1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Functions in Snowflake

Connected

Exercise

Creating your own Snowflake function

The development team is back again, thanks to all of your hard work from before. They'd like to create a "leader board" in the application to rank gym members by the efficiency of their workouts. Efficiency is determined by the number of calories that are burned per minute of working out. The first step to provide this data is creating a function to determine efficiency. Good luck!

Instructions

100 XP
  • Define a function called calories_per_minute with three parameters: start_time and end_time, which are both of the type TIMESTAMP, and calories_burned, which is a NUMBER.
  • Further update the calories_per_minute function to return a NUMBER.
  • Use the DATEDIFF function to find the number of minutes between the check-in and checkout timestamps and divide by the number of calories_burned to determine workout efficiency.
Powered by Snowflake