Sean Lange (2/11/2016)
itsgaurav (2/11/2016)
Select Jcdtl.mdoc_no,Jcdtl.doc,no,jcdtl.doc_dt,jcdtl.del_dt from jcdtlWhere MONTH(jcdtl.doc_dt)=3 AND YEAR(jcdtl.doc_dt)=2014
In this table have approx 10 lacks rcords
Simple to remove these functions and add some range logic.
Select j.mdoc_no
, j.doc_no
, j.doc_dt
, j.del_dt
from jcdtl j
Where j.doc_dt >= '20140301'
and j.doc_dt < '20140401'
That'll do it. And if you have an index on doc_dt, the query will be able to use it. Include doc_no and mdoc_no and it's a covering index. Of course, you'll want to design your indexes so they're used efficiently, which depends on how you use the table.