Sunteți pe pagina 1din 3

1/10/2016

UsingTemporalJointofetchtheresultsetwit...|SCN

GettingStarted Newsletters

Hi,Guest

LogOn

JoinUs

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

Activity

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Browse

Communications

Actions

SAPHANAandInMemoryComputing

UsingTemporalJointofetchtheresultsetwithinthe
TimeintervalinSAPHANA
PostedbyAkshayNayakinSAPHANAandInMemoryComputingonSep28,201412:04:26PM

HelloAll,

Inthisblog,iamgoingtoexplainhowtouseTemporalJoinfeatureavailableinHANAtofetchtheRecordsfrom
transactiontablebasedonTimeintervalfieldsofMasterTable.

Problem:

SometimewecomeacrossscenariowhereinweneedtoanalysethedatabyjoiningTransactiontableandMaster
tableonkeycolumnandfetchthedataforaparticulartimeperiodasspeicifiedinFromandTodatesofMastertable.
InthiscaseweneedtogoforaNonEquijoin.ThiscanbeeasilyachievedthroughScriptbasedViewswhereinyou
useeitherBETWEENoperatoror>and<operator.HowdoweachievethesameusingAnalyticalviewinHANA?

Solution:

ToachievetheabovestatedprobleminAnalyticalview,wehavetogoforaTemporaljoin.Youcreateatemporaljoin
usingthetemporalcolumnthatspecifiesthetimeintervalwiththestartandtheenddate.Theresultsetisfetched
basedonthetimeintervalmappedusingthetemporalcolumn.Thatmeansarecordisonlyincludedintheresultsetif
thetimeintervallieswithinthevalidtimeinterval.ThisfeatureisavailableinSAPHANAstartingfromSP05.

Ihavecreated2tablesProduct_masterandProduct_salestableandloadedwithsampledataasshownbelow,

ProductMaster:

Product_sales:

NowletscreateanattributeviewcontainingmastertableProduct_master.

http://scn.sap.com/community/hanainmemory/blog/2014/09/28/usingtemporaljointofetchtheresultsetwithinthetimeinterval

1/3

1/10/2016

UsingTemporalJointofetchtheresultsetwit...|SCN

AlsowewillcreateAnalyticalviewwithProduct_salestableindatafoundationlayerandletstrytojoinabovecreated
attributeviewinLogicaljoinnode.

Inthelogicaljoin,letscreateatemporaljoinbetweenthedatefieldofthefacttabletoaninterval(toandfrom)fieldof
theattributeview.Thesupporteddatatypesare:timestamp,date,andinteger.
NowselectTemporalcolumnthatindicatestimecolumninfacttable,fromandtocolumnfromattributeviewwhich
specifiestimeintervalandTemporalconditiononwhethertoincludeorexcludeDates.Thevariousoptionsavailable
forTemporalconditionare,IncludetoandExcludefrom,Excludeboth,Includeto.WewillkeepExcludetoandInclude
fromoption.

ActivateandruntheAnalyticalviewandyoucanseetheoutput.

WecanseethatP001productvaluefordate20140310,P003productvaluefordate20140410and20140628
hasbeenfilteredsincetheyfallbeyondthetimeinterval.AlsoyoucannoticeP002productvaluefordate20140426
hasbeenfilteredsincewehavekeptExcludetoandIncludefromoption.

ThusweareabletoachievetheintendedresultthroughAnalyticalview.

Thanksforreadingthisblog,YourSuggestionsandfeedbacksaremostwelcome

Regards,
Akshay

http://scn.sap.com/community/hanainmemory/blog/2014/09/28/usingtemporaljointofetchtheresultsetwithinthetimeinterval

2/3

1/10/2016

2791Views

UsingTemporalJointofetchtheresultsetwit...|SCN

Products:sap_hanaTags:temporal_join,analytical_views

AverageUserRating
(9ratings)

1Comment
PetrStastnyMar5,20153:44PM

Hi,
honestlyIdonotunderstandtheexample.ThetablecontentyouhaveintroducedIwouldcall
inconsistentdatabase.HowcanIhaveasalesforproductwhichisnotvalidforthatdate?
Petr
Like(0)

SiteIndex
Privacy

ContactUs
TermsofUse

SAPHelpPortal
LegalDisclosure

Copyright

http://scn.sap.com/community/hanainmemory/blog/2014/09/28/usingtemporaljointofetchtheresultsetwithinthetimeinterval

FollowSCN

3/3

S-ar putea să vă placă și