I am executing a query in SQL Server as below:
select MAX(id) as id FROM Employee where CONVERT(date,submitted_dt)='2015-07-15' group by EmpId
Here Id
is different column and Empid
is different column ,Id
is primary key with identity
Result is as below:
1720152
1719253
1719676
1719890
1718425
1719440
1718431
1719408
1719461
1717679
..
..
1719532
1719583
1719386
1720200
1720160
1720182
1718967
1720232
1720113
It's around 185 rows, and I am doing NOT IN
statement in the result query
select EmpId,submitted_dt
FROM Employee
where id NOT IN
(select MAX(id) as id FROM Employee where
CONVERT(date,submitted_dt)='2015-07-15'
group by EmpId) and CONVERT(date,submitted_dt)='2015-07-15'
It is running very slow it is taking 2 min.