I am working on creating one view in SAP HANA.
I have column A, Data type for A is NVARCHAR.
Values in A are something like below. I need to use only last 5 digits and convert it into decimal.
A
000000000000000000000000000EF80A
000000000000000000000000000EF812
000000000000000000000000000EF80E
000000000000000000000000000EF809
000000000000000000000000000EF80B
000000000000000000000000000EF80C
000000000000000000000000000EF80D
I made use of function
Select HEXTOBIN(0xEF80A) from dummy;
This gave me required result.
However 0x in above query is notation to mark number (EF80A) as hexadecimal.
Whenever I have to fetch 5 last digit dynamically, I am not able to assign 0x notation.
I tried following:
1) substr last 5 digits of A and concat it with 0x... This did not work, as '0x'is considered as string while it is just notation.
select distinct '0x' || right(A,5 ) from dummy;
Can someone help as to how I give 0x with last 5 char of column A to mark it hexadecimal?
Are there any direct function available for this conversion without user defined function?