The sum of all SQL Server matter that exist,
and the space in which all SQL Server events
occur or could occur.
Welcome to SQL Server Universe.com Sign in | Join | Help
in
Home SS SLUG Forums Articles Photos Downloads
A Merry Christmas
and a
Happy
New Year

to all...

How to get absentee records

Last post 09-05-2008, 7:08 by G.R.Preethiviraj Kulasingham. 1 replies.
Sort Posts: Previous
  • How to get absentee records

     09-04-2008, 13:33

    • Joined on 10-17-2007
    • Posts 6
    • Points 0
    • Top 25 Contributor

    Hi all,

    I have a simple question with the following query

    select distinct convert(varchar,MovementInformation.MovementDateTime,101),Employee.EmployeeName

    from MovementInformation

    inner JOIN Employee ON (MovementInformation.EmployeeId = Employee.Id)

    where Employee.Id in(select * from GetAbsentEmployees('8/1/2008 0:00:00 AM','8/30/2008 11:59:59 PM'))

    and MovementInformation.MovementDateTime

    not in(select * from GetDateRange('8/1/2008 0:00:00 AM','8/30/2008 11:59:59 PM'))

     

    I want to get the absentee records from the above mentioned query. the Get AbsenteeEmployees is a table value function which returns the absent employee IDs.The Get DataRange is also a table valued function which returns all the dates for a given period.eg:- 8/1/2008,8/2/2008

    My problem is i get records but the dates are wrong.The movement information table does not have records if the employee is absent.

    I think there is some wrong with the query.

    Can u plz correct it and send it to me.I am stuck with it.

    Thanks

    Lucki

  • Re: How to get absentee records

     09-05-2008, 7:08

    • Joined on 04-02-2007
    • Colombo
    • Posts 28
    • Points 0
    • Top 10 Contributor
      Male
    Hi Lucki,
    As it is difficult to understand the query without the schema, I am trying to shooty at the dark.
    You are using Employee table to get all the information of Employee and join with a function whcih restricts the data to Absent emplyees only. (Am I correct?) Now you are joining this data to MovementInformation. Do you have data for absent emplyees there? Now you are stating The movement should not be in DateRange (of the same date) What does this mean?

    You may have to run each part seperately and find out the issue. Additionally, If you have null values on a column which you are comparing, it will not appear in the query as any operation with NULL will producce the result of NULL.
    G.R.Preethiviraj Kulasingham MCITP: DBA
    http://preethiviraj.blogspot.com/
    Plan Your Work and Work Your Plan!
View as RSS news feed in XML

(Best viewed with a resolution of more than 1024 * 768)

Powered by Community Server, by Telligent Systems