Codewars Kata SQL

7 kyu

SQL Basics: Create a FUNCTION

For this challenge you need to create a basic Increment function which Increments on the age field of the peoples table.

The function should be called increment, it needs to take 1 integer and increment that number by 1.

You may query the people table while testing but the query must only contain the function on your final submit.

important: you must remove all comments when submitting the kata.

people table schema

  • id
  • name
  • age


CREATE OR REPLACE FUNCTION increment(age integer) returns intAS $$
RETURN age + 1;
$$ LANGUAGE plpgsql;

Another solution:

CREATE FUNCTION increment(i integer) RETURNS integer
AS 'select $1 + 1;'





My homepage to record my thought processes for solving SQL and Algorithm questions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store