Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
avalle
Starting Member
3 Posts |
Posted - 2010-07-30 : 08:17:29
|
| How can I link the values from two tables using a concat value as common reference between them?This is the rough idea of what I want to do:select t1.column_X, t2.column_Y from table1 t1, table2 t2when concat(column_A,column_B,column_C) from table 1 = concat (column_A, c_b, column_C) from table 2Hope guys you have the answer pto this questionAngel V. |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-07-30 : 08:21:10
|
| u want like thisselect t1.column_X, t2.column_Y from table1 t1join table2 t2 on t1.column_A = t2.column_Aand t1.column_B = t2.column_Band t1.column_C = t2.column_C |
 |
|
|
avalle
Starting Member
3 Posts |
Posted - 2010-07-30 : 08:55:47
|
| Many thanks for your answer,Actually my SQL its more complex it looks like:select a.DMDUNIT, a.DMDGROUP, a.LOC, a.FCSTDATE, a.STARTDATE, BASEFCST+NONBASEFCST FCST, h.qty, round(min(lag)/4.3,0) Monthly_Lag, lag Weekly_Lagfrom histfcst a join hist h on a.dmdunit= h.dmdunit and a.loc = h.loc and a.startdate = h.startdate where a.dmdunit= '5046' and a.scen=0 and a.loc <> 'USA' and a.dur=10 and a.dmdgroup='SALES'and a.startdate BETWEEN '01-jan-10' and '30-jun-10' and lag between '7' and '10'group by a.DMDUNIT, a.DMDGROUP, a.LOC, a.FCSTDATE, a.STARTDATE, BASEFCST+NONBASEFCST, lagNow the expression group by is sending me error messege. Do u have any clue how can I do it?Angel V. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-07-30 : 08:58:44
|
| i think u have miss the h.qty in the group by clause........r can u post the error msg...... |
 |
|
|
avalle
Starting Member
3 Posts |
Posted - 2010-07-30 : 09:32:44
|
| I have aggregated h.qty but same error happen, it is as followsError -2147217900 - ORA-00936: missing expressionAngel V. |
 |
|
|
|
|
|
|
|