How to concatenate multiple rows of a column in a table into a single column? I have to concatenate multiple rows to a single column. For example, consider the below teacher’s table. The above table is a normalized table containing the subjects and teacher ID. We will denormalize the table, by concatenating the subjects of…
In this article, I am going to show different ways of deleting duplicating records from the table. It is a common question in interviews which is asked frequently. Consider the following table with rows as an example: Table Name: Products ProductId Price ————— 1 10 1 10 2 20 3 30 3 30 Here, assume…
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: 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…
Application Startup error: But I got ‘Syntax error in SQL statement’ on application startup: Error: 19:08:45.642 6474 [main] INFO o.h.tool.hbm2ddl.SchemaExport – HHH000476: Executing import script ‘/import.sql’ 19:08:45.643 6475 [main] ERROR o.h.tool.hbm2ddl.SchemaExport – HHH000388: Unsuccessful: CREATE TABLE Person ( 19:08:45.643 6475 [main] ERROR o.h.tool.hbm2ddl.SchemaExport – Syntax error in SQL statement “CREATE TABLE PERSON ( [*]”; expected…