Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need help in getting the last row using peek function and below is the sample data.
PeekTest:
LOAD * Inline
[
ID
1
2
3
];
LOAD ID,
Peek(ID,0) as FirstValue
Resident Peek;
By using the above peek function i can able to get the first row into FirstValue field i,e, '1' but when i use 'Peek(ID,-1) as LastValue' i'm getting '1' and '2' but i want to see only '3'.
Can someone help me to identify the issue.
Regards,
Bharath Vikas
Do you need Peek() or can this work instead?
Test:
LOAD LastValue(ID) as LastValue;
LOAD * INLINE [
ID
1
2
3
];
You want to see just one row with 3 or are you looking to see all three rows with 3 in it?
PeekTest:
LOAD * Inline
[
ID
1
2
3
];
NoConcatenate
Final:
Load * Resident PeekTest Order by ID desc;
LOAD ID,
Peek(ID,0) as FirstValue
Resident Final;
@sunny_talwar I want to see one row with 3.
@Frank_Hartmann thanks for that, but my requirement is I want first value and last value. It means if i use 'Peek(ID,0) as FirstValue' i want the result as '1' as below
FirstValue |
1 |
And if i use 'Peek(ID,-1) as LastValue' i want the result as '3' as below
LastValue |
3 |
Do you need Peek() or can this work instead?
Test:
LOAD LastValue(ID) as LastValue;
LOAD * INLINE [
ID
1
2
3
];
@sunny_talwar thanks for that, it works for me and i've modified the script a little bit as below in order to get the firstvalue as well.
Test:
LOAD LastValue(ID) as LastValue, FirstValue(ID) as FirstValue;
LOAD * INLINE [
ID
1
2
3
4
];