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