Selecting MAX date question

Hello there,

I am getting the max date for a specific field(shopNO). Would it be faster if I add another condition just to search for daily requests in the where clause?

SELECT
MAX([RequestDate]) AS[Latest Date]
FROM[Confirm]
WHERE [ShopNo] = '111111'

hi

can you please explain what you "mean" by .. !!!

Would it be faster if I add another condition just to search for daily requests in the where clause?

WHERE [ShopNo] = '111111' and
CONVERT(date,RequestDate)=CONVERT(DATE,getdate())

hi

Any time you use functions .. it degrades performance

Max and Convert both will !!

If you can use > (greater than) its best !!!

Hope this helps
:slight_smile:

thank you @harishgg1, please check my other post :slight_smile:

Yes, it should help a lot if you add a date check. Greater-than doesn't really work here, you need gt_eq.
The appropriate code would be something like this:

WHERE [ShopNo] = '111111' and RequestDate >= CONVERT(DATE,GETDATE())

1 Like