I have a table, something like:
Id Name EnteredOn Percentage
`````````````````````````````````````````````````````````````
01 person1 2011-03-09 17:29:35.683 56.29
02 person1 2011-03-09 17:29:35.731 76.29
03 person1 2011-03-09 18:15:78.683 56.29
04 person1 2011-03-10 17:29:35.683 56.29
05 person1 2011-03-10 16:29:31.683 56.29
06 person1 2011-03-11 17:29:35.683 56.29
To summarize the above table, there are three rows for day 09, and two rows for day 10.
Now, I just want to select the latest row - one single row - per day.
(one row for 9, one for 10 and the one for 11)
I cannot use distinct because of the timestamp. I cant group and use:
CAST(CONVERT(FLOAT, EnteredOn) AS INT)
because when I select EnteredOn field, it complaints that its not grouped. I cant combine distinct(cast..date...)
because I cant get the right syntax.
How can I select - only Name, EnteredOn, Percentage fields with distinct to each day?
many thanks in advance.