sql cross query

Discussion in '.NET' started by SoniaArun, Dec 31, 2012.

  1. SoniaArun

    SoniaArun

    Joined:
    Dec 18, 2012
    Messages:
    2
    Likes Received:
    0
    select a.ecode,b.empname,a.fromdate,a.[to],
    case when c.leavedetails=1 or c.leavedetails=2 then
    (select datediff(dd,a.fromdate,a.[to])-(datediff(wk,a.fromdate,a.[to])*2)-
    case when datepart(dw,a.fromdate)=1 then 1 else 0 end +
    case when datepart(dw,a.[to])=1 then 1 else 0 end +1)
    else
    datediff(dd,a.fromdate,a.[to])+1
    end as days
    ,e.prjname,d.leavetype

    from leavedetails a join empdata b on a.ecode=b.empcode
    join leaverelation c on c.leavedetails=a.id
    join leavetype d on c.leavetype=d.id
    join project e on c.prjid=e.id
     
    SoniaArun, Dec 31, 2012
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.