-5
I’m doing a query where I’m returning the last record of the day(which in case has the days but there are several time records in a day, and I’m picking the last of them in a sub select), the problem is that I can’t sort in the end, it gets shuffled, I’ve tried order by and it doesn’t work. Follow the query:
NOTE: I want to sort the column 'Createdon'
SELECT
rl.WipOrderNo,
CAST(rl.CreatedOn AS smalldatetime) AS CreatedOn,
rl.RegularHours
FROM resource_labor rl
WHERE CAST(rl.CreatedOn AS date) = CAST(rl.CreatedOn AS date)
AND rl.WipOrderNo = rl.WipOrderNo
GROUP BY CAST(rl.CreatedOn AS smalldatetime),
rl.WipOrderNo,
rl.RegularHours
you want to order by what?
– user148170
sort the Createdon column in ascending
– Matheus Berns
what kind of field?
– user148170
datetime, is in sql server
– Matheus Berns