Skip to content

Tag: sql

SQL query grouping by range

Hi have a table A with the following data: I’d like to have the following result: My DB is DB2/400. I have tried with ROW_NUMBER partitioning, subqueries but I can’t figure out how to solve this. Answer I understand this as a gaps-and-island problem, where you want to group together adjacent rows …

Find the max value in the last digit

I am using MySQL 5.5. I am facing a problem on how to find the max value in the last digit. For example below the table, I want to get the max value is detected the last digit. The result should be …

Print out everything from table 1 and matching data from table 2

I am trying to learn sql and I came across a basic question. This problem mainly focuses on the join, which join to use in order to execute the correct data. What queries I should write to validate and compare between these two tables? Let’s say I have two tables (parent and child): Parent has two colum…