Hi All,
I've just been trying to get the RIGHT() statement to work but I'm getting some funny results when used in conjunction with other SQL statements, such as RAND(), CONCAT() and TO_NVARCHAR().
I'm not sure if it is a bug, by design or simple my own syntax error.
I have the following results:
1) Incorrect results using RIGHT(...,5).
select top 50 right(concat('00000',to_nvarchar(round((rand() *100),0))),5) as "PADDED" from objects cross join objects;
Notice: that I have some entries above with length 6.
2) Correct Results using RIGHT on the results of a SUB Select
select right(concat('00000', "PADDED"),5) as "PADDED"
from ( select top 50 to_nvarchar(round((rand() *100),0))as "PADDED" from objects cross join objects );
Note: All entries are correctly formatted to 5 in lengh.
The damn things been sending me mad for hours now trying to get it to work without a SUB Select, but I've not cracked it yet.
My HANA Database is version Rev 67, and Studio is Rev 68.
If people can work out the correct syntax for option 1) then please let me know.
Please do specify you Database and Studio version in any response.
I'll owe a Beer to the first person with the correct answer.