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 |
smitha
Posting Yak Master
100 Posts |
Posted - 2010-01-08 : 05:14:52
|
I am having 2 tables with the same date and time. I am using cross joins to join the 2 tables. For each date and time, I am clubbing the values of both the tables. ex: table16:00:00 am tag1 = 45, tag2= 34table26:00:00 am tag3 = 12, tag4=78Now I am joining table1 and table2 and the result should be6:00:00 am tag1,tag2,tag3,tag4but I am getting the result as6:00:00 am tag1,tag2,tag3,tag46:00:00 am tag1,tag2,tag3,tag4The answers are getting multipled.can anyone help on thisSmitha |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-01-08 : 05:19:57
|
select t1.time_col,tag1,tag2,tag3,tag4 from table1 t1 inner jointable2 t2 on t1.time_col=t2.time_colSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
|
|
smitha
Posting Yak Master
100 Posts |
Posted - 2010-01-08 : 06:20:58
|
Thanks I was able to get the resultquote: Originally posted by senthil_nagore select t1.time_col,tag1,tag2,tag3,tag4 from table1 t1 inner jointable2 t2 on t1.time_col=t2.time_colSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/
Smitha |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-08 : 07:22:46
|
quote: Originally posted by smitha I am having 2 tables with the same date and time. I am using cross joins to join the 2 tables. For each date and time, I am clubbing the values of both the tables. ex: table16:00:00 am tag1 = 45, tag2= 34table26:00:00 am tag3 = 12, tag4=78Now I am joining table1 and table2 and the result should be6:00:00 am tag1,tag2,tag3,tag4but I am getting the result as6:00:00 am tag1,tag2,tag3,tag46:00:00 am tag1,tag2,tag3,tag4The answers are getting multipled.can anyone help on thisSmitha
Why did you use Cross join? Do you know what it does?MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|