| Author |
Topic |
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2010-08-05 : 09:26:30
|
| Hi,I have two fact tables. And I need to see the all data for both.But I need to group by the columns what exist in both tables, without lost the others columns. (like two outer joins, for both sides)How can I do this? What type of join can I use?Many Thanks!Regardssantana |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-05 : 09:30:58
|
Try:select ... from table1UNIONselect ... from table2UNION will not return duplicate rows except they have a column with different values.If that isn't what you want then give table structure, example data and wanted result. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ewomack
Starting Member
33 Posts |
Posted - 2010-08-05 : 09:39:09
|
| If you need to group the results, then you'll want to use a join. To see everything you can use a FULL join that will return everything from both tables and allow grouping on the results.I think this is what you need, but can you give data samples to confirm?Ed Womackwww.getmilked.com |
 |
|
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2010-08-05 : 09:42:37
|
| Ok.But with union, I need to have the same colums, yes?Fact A:cod cod2 valueA date100 xxx 10 201108101 xxx 30 201108103 yyy 40 201108Fact Bcod2 valueB datexxx 100 201108yyy 200 201108If I use union for this two tables, I will lost the infoamrtion about cod, yes?Thank you for your help!!!Regards, |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-05 : 09:45:49
|
What should be the output in relation to your sample data? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ewomack
Starting Member
33 Posts |
Posted - 2010-08-05 : 09:54:14
|
| Yes, union requires having the same columns, or at least heavily compatible columns. It's unclear to me whether you need a union or a join, but it sounds more like you need a join.Ed Womackwww.getmilked.com |
 |
|
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2010-08-05 : 10:24:38
|
| I think I need a join, but I cant exclude any register......????thank you! |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-08-05 : 10:53:47
|
| Please refer to this link and restate your questionhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
|