LEaves

  • Hi.

    i am using this query.

    SELECT

    w.eID, w.ename,

    COALESCE(al.CheckTime, c.[Date]) AS [Date]

    ,CASE WHEN al.CheckTime IS NULL THEN ld.Description ELSE 'P' END AS Attendance

    FROM dbo.employee AS w

    CROSS JOIN dbo.Calendar AS c

    LEFT JOIN dbo.AttendLog AS al

    ON al.eID = w.eID

    AND DATEDIFF(DAY, al.CheckTime, c.[Date]) = 0

    left join LeaveInformation l on COALESCE(al.CheckTime, c.[Date]) =l.date

    left join LeaveDescription ld on l.lid =ld.lid

    WHERE c.[Date] = '20130815'

    when i write ld.Description its gives me null data like this

    eid----------name--------------date----------------attendance

    101881--------A----2013-08-15 00:00:00.000-----------NULL

    101798--------B----2013-08-15 00:00:00.000-----------NULL

    101775--------C----2013-08-15 00:00:00.000-----------NULL

    but when i use 'A' instead of ld.Description its gives me that result

    eid----------name--------------date----------------attendance

    101881--------A----2013-08-15 00:00:00.000-----------A

    101798--------B----2013-08-15 00:00:00.000-----------A

    101775--------C----2013-08-15 00:00:00.000-----------A

    i want to write ld.descriprtion instead of A

    Please help me out Thanks

    immad

  • Can you check in table if ld.Description has some values other than NULL? Query looks fine otherwise.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply