Hello all,
I am struggling with a query and need your help!
I am trying to turn this:
| Parent | Component |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
| 5 | 6 |
| 6 | 7 |
Into this:
| Parent | Component |
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 1 | 5 |
| 1 | 6 |
| 1 | 7 |
Here is the code that i have thus far, but i can not get it to work.
Snums = Open Database(
"DSN="Connection string...",
"SELECT [dbo].[BOM].[PARENT] as PARENTID ,[dbo].[BOM].[COMPONENT] as SUBPARENTID
FROM [dbo].[BOM] --as tb1
--LEFT JOIN [dbo].[BOM] ON [dbo].[BOM].[PARENT] = [dbo].[BOM].[COMPONENT]"
);
Snums << New Column( "SUBPARENTID2", Character );
For( i = 1, i <= N Rows( Snums ), i++,
r = Snums << Get Rows Where( :PARENTID == :SUBPARENTID[i] );
If(
N Rows( r ) == 0, Continue(),
N Rows( r ) == 1 & r[1] == i, : SUBPARENTID2[i] = 0,
N Rows( r ) == 1, : SUBPARENTID2[i] = : SUBPARENTID[r[1]],
: SUBPARENTID2[i] = : SUBPARENTID2[i]
););
I am trying to learn JMP code as fast as possible (new job) but am under a tight deadline with this one. Please help!
);
);