Solving the Odd and Even Measurements Puzzle with SQL

A Simple SQL Approach to Odd and Even Measurements

Lorena Gongang
Learning SQL

--

Image by Arek Socha on Pixabay

Besides working on personal projects, a good idea is to practice programming skills and develop problem-solving skills through coding games.

Learning SQL, Python, and algorithms is essential for anyone wanting to pursue a Data engineering career. There are a considerable amount of platforms that help practise and work on programming skills.

In this article, I will present a SQL problem I resolved on Datalemur. I chose a medium-difficulty question from the company Google.

The problem :

Assume you’re given a table with measurement values obtained from a Google sensor over multiple days with measurements taken multiple times within each day.

Write a query to calculate the sum of odd-numbered and even-numbered measurements separately for a particular day and display the results in two different columns. Refer to the Example Output below for the desired format.

Definition:

Within a day, measurements taken at 1st, 3rd, and 5th times are considered odd-numbered measurements, and measurements taken at 2nd, 4th, and 6th times are considered even-numbered measurements.

--

--

Lorena Gongang
Learning SQL

Data Enthusiast | Data Engineer | Learning, sharing and building my online presence. Also write at https://lorenagongang.com/