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

GROUPING in HANA SQL

$
0
0

Hi Experts,

 

Here is what I am trying to do,

I have first 4 columns on the existing Table (HCC_PERNR, HCC_ZBEGDA, HCC_ZENDDA and HCC_OBJ)

 

I am trying to code for the last Column HCC_GROUP (group the values on change of HCC_OBJ)

 

Note : I can do that easily but there is one catch ; see HCC_OBJ -> 36000360 is coming twice , once from 2010 to 2011 and then from 2014 to 9999

 

_HCC_PERNR_HCC_ZBEGDA_HCC_ZENDDA_HCC_OBJ_HCC_GROUP
10007304200706072008040501
100073042008040620090905350020042
100073042009090620090919350020042
100073042009092020100710350020042
100073042010071120101225360003603
100073042010122620110723360003603
100073042011072420120107360003614
100073042012010820120331360003614
100073042012040120120624360003614
100073042012062520130427360013835
100073042013042820130720360013835
100073042013072120140104360013835
100073042014010520140118360003606
100073042014011920140301360003606
100073042014030299991231360003606

 

 

after I get above I want to write following

 

SELECT HCC_PERNR, MIN(HCC_ZBEGDA) , MX(HCC_ZENDDA), HCC_OBJ, HCC_GROUP

FROM <ABOVE SELECT>

GROUP BY HCC_PERNR,HCC_OBJ, HCC_GROUP

 

The above statement should give me two rows for 36000360 (once during 2010/2011 & other one During 2014/9999)

 

 

 

If I just write the GROUP statement without the HCC GROUP , I would loose the split of 36000360 ; it would actually tell me 36000360 was from 2010 to 9999 ; which is wrong.

 

Thanks

Meps


Viewing all articles
Browse latest Browse all 9052

Trending Articles



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