Focal Point
[solved]join help

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/57910016

March 27, 2009, 03:28 PM
krish
[solved]join help
Hi all,
I have two tables with the following structure
TABLE1 NAME==> EMPLYOEE_score
EMP_ID--Period_id-score
1------------1----------2
1------------3----------1
2------------1----------3
2------------2----------2
2------------3----------0
3 3 3

TABLE2 NAME==> Periods

Period_id
1
2
3

All I want is, I need to join these two tables such a way that my resultset should look like this(need to show all the Period_id for each emp_id and add the values of scores for each emp_id )

EMP_ID Period_id score
1 ----------1----------2
1 ---------- 2----------2
1 ---------- 3----------3
2 ---------- 1----------3
2 ---------- 2----------5
2 ----------3----------5
3 ---------- 1----------0
3 ---------- 2----------0
3 ---------- 3----------3

I was trying with outer joins but didnt get the expected result.

Thanks
krish.

WebFOCUS 7.6.5 UNIX EXCEL

This message has been edited. Last edited by: krish,
March 27, 2009, 03:33 PM
kfr104
Are you joing single or multiple?


WebFocus 7.6.4
SQL
HTML and Excel
March 27, 2009, 03:50 PM
krish
Hi Kfr104

I Tried with SQL and focus multiple joins but no luck... Frowner Confused


7.1.1
Windows XP
HTML
March 27, 2009, 04:43 PM
GinnyJakes
Try left outer join and the LAST function to calculate the score in a compute:

NEW_SCORE/I4=IF EMP_ID NE LAST EMP_ID THEN SCORE ELSE LAST NEW_SCORE+SCORE;


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
March 28, 2009, 03:26 AM
krish
HI GINNY,
thanks for your reply... i got your soution for accumulating the score value.

left outer join won't work for this case because in the periods table i dont have all the emp_id's of employee_score.

what is expectation is for every emplyee_id i need all the period_id (with the score eq 0 for missing record)

Thanks
krish


7.1.1
Windows XP
HTML
March 30, 2009, 05:13 AM
GamP
Krish,
You may want to look up the MATCH command. I'm confidant that you will accomplish what you need if you use the MATCH command to collect the data into one intermediate hold file. Once that is done, use Ginny's method of calculating the scores.

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988