Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2800

Problem with converting SQL query to HANA

$
0
0

Hi experts,

 

I'm new to SAP HANA database. I have to convert some  MS SQL queries to HANA and I could convert all the basic queries except one. This query has lot of SQL functions used and I don't know what are the functions I can use instead in HANA. I tried to use the provided SAP HANA - SQL converter but it didn't give me working query as an output. Below you can see the original SQL query and the output of the converter(which is wrong). Can some one help me to convert this query?  I'm just an intern

 

 

ORIGINAL SQL QUERY :

 

SELECT T0.[BirthDate], T0.[CardCode], T1.[CardName], T0.[Name], T0.[Tel1], T0.[E_MailL] FROM OCPR T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode WHERE 1 = (FLOOR(DATEDIFF(dd,T0.[BirthDate],GETDATE()+" + period + ") / 365.25)) - (FLOOR(DATEDIFF(dd,T0.[BirthDate],GETDATE()-" + period + ") / 365.25))

here "period" is an integer value.

 

 

HANA QUERY GOT FROM CONVERTER :

 

SELECT T0."BirthDate", T0."CardCode", T1."CardName", T0."Name", T0."Tel1", T0."E_MailL" FROM OCPR T0 INNER JOIN OCRD T1 ON T0."CardCode" = T1."CardCode" WHERE 1 = (FLOOR(DAYS_BETWEEN(T0."BirthDate", ADD_DAYS('1900-01-01 00:00:00.000', NOW() + " + period + ")) / 365.25)) - (FLOOR(DAYS_BETWEEN(T0."BirthDate", ADD_DAYS('1900-01-01 00:00:00.000', NOW() - " + period + ")) / 365.25));

ERROR:

invalid name of function or procedure: DATEDIFF


Viewing all articles
Browse latest Browse all 2800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>