#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    1
    Rep Power
    0

    Get Time defaulters list


    Following are the table details
    1.
    name: time_tbl
    columns:
    time_id
    employee_id
    time_date (date)
    time_start(time)
    time_end(time)
    time_details(text)

    2.
    name: employee_tbl
    columns:
    employee_id
    employee_name(varchar)
    employee_join_date(datetime)

    Everyday employees enter their time entries and their task details. I want to have list of employees that did not fill their time entries between a given date range.

    If the date range is more than one day and the employee has not entered time details for more than one day in between the range, then the employee name should appear more than once with respect to date.

    Required output

    date | employee_id | employee_name
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    724
    Rep Power
    291
    If the time_tbl will always have a record for each day then try this.

    Code:
    SELECT 
    	time_date, 
    	e.employee_id, 
    	e.employee_name
    FROM employee_tbl e
    LEFT JOIN time_tbl t on e.employee_id = t.employee_id
    WHERE time_date between @startdate and @enddate
    	AND (time_start is null or time_end is null)

IMN logo majestic logo threadwatch logo seochat tools logo