how to fetch record(s) which is having

  • Hi

    I have one table which is having some records as below.

    reqno empno deptno fromdate vac_days

    1 4230165 201135 1429/07/03 5

    2 4230165 201135 1429/07/10 4

    3 6000144 201135 1429/07/15 6

    4 6000144 201135 1429/07/15 5

    5 6000103 201136 1429/07/15 4

    now, i want records of all empno which vacation days are less than 10 days.

    the output should be like.

    1 4230165 201135 1429/07/03 5

    2 4230165 201135 1429/07/10 4

    5 6000103 201136 1429/07/15 4

    here only 6000144 empno record(s) will not be displayed because it has vacation days total more than 10 days.

    Please help me.

  • Try this:-

    select reqno, v.empno, deptno, fromdate, vac_days

    from vacation v

    inner join (select empno, sum(vac_days) as vacdays

    from vacation

    group by empno

    having sum(vac_days) < 10

    ) as x

    on v.empno = x.empno

    order by reqno

  • Hi,

    Yo uhave the answer to your question, but i would like to know why do you want to display two records for same Employee? Shouldn't it be only one record for an employee??

    Thanks -- Vj

    http://dotnetvj.blogspot.com

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

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