© Kim Berg Hansen 2020
K. Berg HansenPractical Oracle SQLhttps://doi.org/10.1007/978-1-4842-5617-6_18

18. Grouping Data Through Patterns

Kim Berg Hansen1 
(1)
Middelfart, Denmark
 

Grouping data with a group by clause requires you to find one or more values that are the same in those rows you want to belong to the same group. Often that is simply some columns or just as often a calculation on some columns.

Sometimes, though, the condition that tells you a row belongs to a group is not simply a condition you can calculate using only values from that row itself, but the condition is on how the row relates to other rows. A condition to group by could, for example, be that all rows with consecutive sequential values should be grouped – when a gap in the ...

Get Practical Oracle SQL: Mastering the Full Power of Oracle Database now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.