SELECT AdDate, AdTime, FK_StationId, CAST(rank() over(partition by fk_stationid order by addate,adtime) AS VARCHAR(10)) + ' of ' +
CAST(count(*) over(partition by fk_stationid) AS VARCHAR(10)) as Position
FROM dbo.TestTable
GROUP BY AdDate, AdTime, FK_StationId
HAVING (AdDate = CONVERT(DATETIME, '2013-04-01 00:00:00', 102))
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537