I have a query as follows:
WITH CTE AS (
SELECT MIN(att.Date) [minDate]
FROM Attendance att
WHERE att.Date between '12/01/2011 00:00:00'
AND '12/31/2011 00:00:00'
AND att.EmpID = 4700
GROUP BY EmpID, CONVERT(VARCHAR, att.Date , 111)
HAVING MIN(CONVERT(VARCHAR, att.Date , 8)) > '09:00:00')
SELECT COUNT(minDate) FROM CTE
I need to use it in a C# application but I can’t just use the query as it says that the query must start with a select or from keyword. I need this query to work in HQL. Please help.
finally it worked with these