SQL Language (MOSC)

MOSC Banner

how to combine sequential rows based on previous or next row

edited Jan 27, 2023 10:40PM in SQL Language (MOSC) 4 commentsAnswered

There is a table I need to join back to itself to created a purchased parts report. But, I keep getting duplicated rows.

How to create a sql that will combine rows based on value of the next row?

Order No and Order Line fields uniquely identify a row in a sales order.

CP_COMP_SEQ is simply a list of all the components needed to manufacture Sales Order and Order Line.

MFG_PURCH_FLG is a flag 'M' means it's a Make part. 'P' means it's a part we need to Purchase.

If an M row follows another M row, then the first component has no purchased parts. If one or more P row(s) follow an M row, then all those sequential rows need to be purchased. Meaning we need to add them to a Purchase Parts report for a buyer to fill out a Purchase Order.

Tagged:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center