I have following query
select ROW_NUMBER() over(order by [emp_no] ) as RowId,
emp_no,
pc_ip,
count(1) as count into #tmp
from ip_track
group by emp_no, pc_ip
select *
from #tmp
where emp_no in ('e44920','e39787')
and I have selected only 2 employee records for an example.. this query will give me following data
RowId emp_no pc_ip count
790033 E39787 172.29.22.36 1
790034 E39787 172.29.23.48 3
790035 E39787 172.29.23.49 37
790036 E39787 172.29.23.50 724
790037 E39787 172.29.23.53 18
790038 E39787 172.29.23.17 48
790039 E39787 172.29.24.38 325
790040 E39787 172.29.31.183 1
790041 E39787 172.29.23.45 7
790042 E39787 172.29.23.18 5
790043 E39787 172.29.23.34 1
790044 E39787 172.29.22.31 1
790045 E39787 172.29.23.40 2
790046 E39787 172.29.23.55 56
790047 E39787 172.29.22.43 1
790048 E39787 172.29.23.10 2
790049 E39787 172.29.23.58 6
790050 E39787 172.29.23.54 3
790051 E39787 172.29.21.36 25
790052 E39787 172.29.23.43 11
790053 E39787 172.29.24.121 4
846618 E44920 172.29.24.34 1
846619 E44920 172.29.23.55 1292
846620 E44920 172.29.23.34 12
846621 E44920 172.29.23.10 1
846622 E44920 172.29.23.58 2
846623 E44920 172.29.23.40 11
846624 E44920 172.29.23.48 39
846625 E44920 172.29.23.45 1
846626 E44920 172.29.23.50 8
846627 E44920 172.29.23.53 2
846628 E44920 172.29.23.17 7
846629 E44920 172.29.24.38 31
846630 E44920 172.29.21.36 10
846631 E44920 172.29.23.43 14
846632 E44920 172.29.23.54 15
Now I want to find max data from this record for distinct employe so that output will look like as follow
RowId emp_no pc_ip count
790036 E39787 172.29.23.50 724
846619 E44920 172.29.23.55 1292
I want to get only max count data..how can I do this please reply.. Thanks in advance.