views:

17

answers:

0

Can someone put this into Nhibernate Criteria ?

select u.* 
from dbo.tblPunch p
inner join tblUsager u on u.USAGER_CODE = p.userId
inner join
(
select distinct(userId), max(datecreation) as DateLastPunch
from dbo.tblPunch
where ServiceId = 76629
group by userId
) lastPunch on p.userId = lastPunch.UserId and p.DateCreation = lastPunch.DateLastPunch and PunchTypeId = 1

The Query is used to return all users having their last punch of type 1 for a service.