How to count number of non-consecutive values in a column using SQL?
Following-up on my question here . Say I have a table in an Oracle database like the one below (table_1) which tracks service involvement for a particular individual: name day srvc_ inv bill 1 1 bill 2 1 bill 3 0 bill 4 0 bill 5 1 bill 6 0 susy 1 1 susy 2 0 susy 3 1 susy 4 0 susy 5 1 My goal is to get a summary table which lists, for all unique individuals, whether there was service involvement and the number of distinct service episodes (in this case 2 for bill and 3 for susy), where a distinct service episode is identified by a break in activity over days. To get any service involvement, I