Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 how to fetch record(s) which is having

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2008-07-04 : 09:57:58
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.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-04 : 10:50:32
Select t1.* from your_table t1 inner join
(
select empno from your_table group by empno having sum(vac_days)<10
) as t2
on t1.empno=t2.empno

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-07 : 02:23:35
or use in:-

Select * from your_table where empno
in
(
select empno from your_table group by empno having sum(vac_days)<10
)
Go to Top of Page
   

- Advertisement -