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 2005 Forums
 Transact-SQL (2005)
 Query to get dates

Author  Topic 

mrleokarthik
Starting Member

16 Posts

Posted - 2007-07-13 : 04:16:05
please let me know answer for this query ?

Attendance table contains date field dtworking.

List all dates that are not in dtworking for the given month.

eg.,
if suppose attendance were marked for 1-jan-2007 and 2-jan-2007 (dtworking), i should get a record list from 3-jan-2007 to 31-jan-2007 for given month Jan

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-13 : 04:34:13
try LEFT JOIN


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

mrleokarthik
Starting Member

16 Posts

Posted - 2007-07-13 : 04:51:27
quote:
Originally posted by khtan

try LEFT JOIN


KH
[spoiler]Time is always against us[/spoiler]





I have only one Table (Attendance table). How can i use join here
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-13 : 04:53:58
do you have a calendar table ? if not you can use this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519&SearchTerms=F_TABLE_DATE

Left join the calendar table to the Attendance table


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

mrleokarthik
Starting Member

16 Posts

Posted - 2007-07-13 : 07:44:16
quote:
Originally posted by khtan

do you have a calendar table ? if not you can use this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519&SearchTerms=F_TABLE_DATE

Left join the calendar table to the Attendance table


KH
[spoiler]Time is always against us[/spoiler]





Thanks Mr.khtan for your quick reply.
It helped me.
I used 'Except' instead of using 'Outer join'


Go to Top of Page
   

- Advertisement -