SQL Tutorial

SQL Functions

Source: Bro Code

Functions

Functions group reusable logic behind a name you can call anywhere.

SQL
CREATE FUNCTION course_count() RETURNS INTEGER AS $$
  SELECT COUNT(*) FROM courses;
$$ LANGUAGE sql;
Try it Yourself
Run this SQL example in your local environment or course sandbox.