-
Junior Member
MAX(Date) Function SQL Server
Hi,
Iave this SQL that should return recors with MAX(DateTimeCreated). DB has 2 records 1 with 01/31/08 and 1 with 01/18/2008. My SQL is returning 01/18/2008; I do not know why? Can someone guide me please? Thanks
select ejhcoid,ejheeid,
max(ejhdatetimecreated) as maxdatetimecreated
from ULTIPRO_FREE.dbo.EmpHJob
where
EjhEmplStatus <> 'T' and
ejhdatetimecreated between '2008/01/01' and '2008/01/31'and
ejhisratechange = 'Y' and
ejheeid = '5U8FX30000K0'
group by ejhcoid,ejheeid
-
Re: MAX(Date) Function SQL Server
Does both the records satisfy the condition in the where clause of the query ?
-
Expert Member
Re: MAX(Date) Function SQL Server
select ejhcoid,ejheeid,
max(ejhdatetimecreated) as maxdatetimecreated
from ULTIPRO_FREE.dbo.EmpHJob
where
EjhEmplStatus <> 'T' and
ejhdatetimecreated between '2008/01/01' and '2008/01/31'and
ejhisratechange = 'Y' and
ejheeid = '5U8FX30000K0'
group by ejhcoid,ejheeid
Problem may be with ejhisratechange. Both the records may not satisfy this codition.
-
Expert Member
Re: MAX(Date) Function SQL Server
Hi, your looks correct and as you call aggreagate function is also correct , please check with DB if both the records have same fields.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules