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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 inner join question number of rows apear

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-11-12 : 07:54:53
I have lot of individual query's run to get PTO and Other hrs , prodHrs etc.

All have common primary key columns: Year(4 digit), Month(int), ACct_unit(int)

PTO query getting 43k rows
Other hrs getting 41.5k rows
Prodhrs getting 44k rows.

When i do inner join based on the primary key columns will all my rows appear?

the max rows here in the above scenario is 44k rows.

I don't want to miss any rows of any type.

These query objects are part of an etl tool.

Thanks a lot for the helpful info

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-11-12 : 08:05:54
The INNER JOIN returns only the rows for which there are equal values in the joined columns.
So we can't know if all of your rows will appear because we don't know your data


Too old to Rock'n'Roll too young to die.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2013-11-12 : 09:59:48
I want all rows rows to appear for all types. based on three primary keys values.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-12 : 12:55:07
Based on what info you gave only think I can suggest is to use FULL OUTER JOIN among tables so that you dont miss any records. and in SELECT use COALESCE() over all columns to make sure you display value even for records missing in one of the tables.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -