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 - 2010-08-18 : 17:38:11
I have simple sub query that pulls in a date range, and an employee id
and another table that has more detail and dates, and employee id's

I need to show fill in the blanks for the dates so if 8-6 was missing it needs to be merged with the right table and the rest can be null.

gavakie
Posting Yak Master

221 Posts

Posted - 2010-08-18 : 17:53:44
Heres my query!

Select ttDates.*
From #ttTemp
Right Join (Select *
From smb.dbo.vw_p_date_ref
Where DTE between (Select [BEG COMM DATE]
From AnalystSpace.dbo.DIRECT_SALES_PAYPERIOD p
Where p.[END COMM DATE] in ('08/14/2010')
)
and '08/14/2010')ttDates
on ttDates.DTE = #ttTemp.Create_dte
Where SalesRep_oor = 40251
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-19 : 13:34:15
which tables is having all dates and which one is missing details?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -