Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: Join two tables having time period data

$
0
0

I was doing it tooo fast, so my guilty conscious made me take another look...I made a typefeler in second select (copy paste is mother of..), but it wouldnt work anyways...I guess you want to chop up time for salarys so something like this is what You need  (beware this is maybe not exactly Hana syntax )

 

select

T1.EMPID,

(CASE WHEN T2.DATEFROM < T1.DATEFROM THEN T1.DATEFROM ELSE T2.DATEFROM END) AS DATEFROM,

(CASE WHEN T2.DATETO < T1.DATETO THEN T2.DATETO ELSE T1.DATETO END) AS DATETO,

CC,

SALARY

from T1  inner join  T2

ON T1.EMPID = T2.EMPID AND ( T1.DATEFROm BETWEEN T2.DATEFROM AND T2.DATETO

OR T1.DATETO BETWEEN T2.DATEFROM AND T2.DATETO)

 

I think this is what you need..correct me if I'm wrong, or if I made an error (have no Hana at home so cant check )


Viewing all articles
Browse latest Browse all 9165

Trending Articles



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