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 2000 Forums
 Transact-SQL (2000)
 leftouter join to fetch

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-12-08 : 08:17:01
srinivasa rao writes "I'm having one table called "tblemp" and its having employee records with "empid" as primarykey.I'm having another table "tblempreposit" and its having employee attendece records for different dates by referencing the "empid" in tblemployee table.
I want to retrive records by writing a join query in such a way that employee record should return for a date existed in the "tblempreposit" table by referencing empid.Suppose if employee record doesn't exist in the tblempreposit for a particular date with reference to an empid,i just want to have record on that particular date with employeename,date and other columns with null values.
I hope i'll this problem to be solved with ur assistence.
thanku.
srinivas"

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2005-12-08 : 12:02:47
You need a table of dates, or better yet a table of sequential numbers from which you can generate date sequences beginning on any particular day. Then cross-join that to your emp table to get a list of all dates for each employee, and then left outer join to your tblempreposit to get detail information where a matching record exists.
Go to Top of Page
   

- Advertisement -