Choose Language Hide Translation Bar
Highlighted

## How many ways to write JSL code for sum of the first five rows of a column in a table?

HLPE
For example, take Big Class. JMP as an example. First, the "age" of column 2 is sorted downward, and then the sum of the values of the first five rows of column 2 is calculated.How many ways can this be written in JSL code?Thank you very much!

The following code is incorrect:

dt = Open( "\$SAMPLE_DATA/Big Class.jmp" );
col = Column( dt, 2 );
dt << Select Where( col[] > 14 & row()<=5 );
n = Col Sum(col[],Selected());

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: How many ways to write JSL code for sum of the first five rows of a column in a table?

try something like

sum(dt[ 1::5, 2 ] ) or sum(dt[1::5, "age" ] )

https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013

Craige
2 REPLIES 2

## Re: How many ways to write JSL code for sum of the first five rows of a column in a table?

try something like

sum(dt[ 1::5, 2 ] ) or sum(dt[1::5, "age" ] )

https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013

Craige

## Re: How many ways to write JSL code for sum of the first five rows of a column in a table?

Thank you very much! I have too little.