Tag: query


  • SQL Query to Group / Aggregate N Consecutive Rows

    Interview Question: In one of my project, I got a requirement to group N consecutive rows and find the min, max and sum of values in each group. In this article, I will show you how to do aggregation on N successive rows. Let’s take the sales table as an example. The data in the…

  • Self Join – How to Write Self Join Queries Easily

    Self Join: By definition, a self join query is a query in which the table is joined to itself. Self joins are written in cases where there is parent child relationships in the data. Let’s take the classic example of employees table. We have to write a self join query to find out the immediate…