Supose I have data in below format
FIELD1 F2 F3
LIN0_TMP A0 1
LIN0_TMP B0 2
LIN0_TMP C0 3
LIN_TMP A 1
LIN_TMP B 2
LIN_TMP C 3
LIN_TMP D 4
LIN2_TMP A2 1
LIN2_TMP B2 2
LIN2_TMP C2 3
LIN2_TMP D2 4
i WANT output in below format using oracle sql query.
FIELD1 F2 F3 FLOW
LIN0_TMP A0 1 FLOW1
LIN0_TMP B0 2 FLOW1
LIN0_TMP C0 3 FLOW1
LIN_TMP A 1 FLOW2
LIN_TMP B 2 FLOW2
LIN_TMP C 3 FLOW2
LIN_TMP D 4 FLOW2
LIN2_TMP A2 1 FLOW3
LIN2_TMP B2 2 FLOW3
LIN2_TMP C2 3 FLOW3
LIN2_TMP D2 4 FLOW3
Number of record for field1 is not fixed for each LIN_TMP value..
This solution uses an analytic sum to generate a running total of the number of times F3 = 1.
Here is the SQL Fiddle.
As I mentioned in my comment, your sort order for FIELD1 is wack, so you will need to supply your own ORDER BY column for the window clause.