7 kyu

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.

people table schema

  • id
  • name
  • age

Solution:

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

Another solution:

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

Link

Reference

--

--

--

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

Recommended from Medium

Surprising Results in the 2020 Python Developers Survey

Selenium WebDriver API — Hierarchy of WebDriver — Test Automation

Terraform Libraries for Azure — Blog 2

Android Rooting Reason Not To Root Android Device

BraveFrodo is a collection of 10,000 unique NFTs,one of the most undervalued project which give you…

How Unix Works: Everything You Were Too Afraid to Ask

A Thank You Note to Celebrate My 1 Year with LinkAja

On the decision-theoretic nature of choosing a digital contact tracing app

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
Jen-Li Chen

Jen-Li Chen

In love with telling stories with data

More from Medium

Top 05 SQL Query Optimization Tips | Devstringx

SQL Query Optimization

What is SQL?

A complete guide to SQL from scratch

SQL Server Indexes: Interview Questions