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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Join Help

Author  Topic 

gavakie
Posting Yak Master

221 Posts

Posted - 2011-04-04 : 16:58:59
I have table and at any time one table could have more then the next but that oculd change as well. How do I join on the table with the most data?

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-04-04 : 17:06:37
describe 'join on'...

what does having more mean?

seems to be a bit of an odd requirement.

Select
From
(
Select * From
(
Select tName = 't1', * From t1
Union All
Select tName = 't2', * From t2
) A
Where tname = case when (select count(*) from t1) > (select count(*) from t2) then 't1' else 't2' end
) Z
Join someOtherTable
On blah blah blah



Corey

I Has Returned!!
Go to Top of Page

gavakie
Posting Yak Master

221 Posts

Posted - 2011-04-04 : 17:12:00
So I need these to be on the same lines I have a table say

Select * From Sales

Also table

Select * From Connects

One Day Sales could have more record one day connects could I need to join on the common key but make sure all the data from all tables always shows.

Ive Tried a full join on one column but it still brings just the common lines like its doing an inner join.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-04-05 : 06:58:24
Show us what you tried when you did your full join...

if you put a where clause on the full join, it's likely that you unintentionally filtered out data you wanted to see.

Corey

I Has Returned!!
Go to Top of Page
   

- Advertisement -