hi,
I am venkat i have one Requirement that is
at present in my hand one table 4 columns like as follows
Emp_No Date Punch_Time In_Out
1 110206 0930 p10
1 110206 0938 p20 (i want eliminate this record)
1 110206 0950 p10
2 110206 0930 p10
2 110206 0950 p20( i want eliminate this record)
2 110206 1010 p10
3 110206 0930 p10
like this i have lot of records.
I want select only Emp_NO two time i.e first in and last out if it has other wise no need two times
1 110206 0930 p10( first in)
1 110206 0950 p20( lastout)
2 110206 0930 p10
2 110206 1010 p10
3 110206 0930 p10
i hope u understand my requirement. i am waiting for Suitable answer.
Regards
venkat
Krishna GaradPosted Feb 7, 2011, 12:49 AM
Declare @regcount int
Set @regcount=(Select Count(EmpNo) From TableName Where EmpNo=@empno)
if(@regcount is null)
Set @regcount=0
else if(@regcount<2)//will give only 2 records selection you can change it
// Your operation
else
Raiserror('message',15,1)