Zaznaczanie pierwszych n wierszy w grupie według klauzuli
Mam schemat podobny do następującego:
<code>create table bar ( instrument varchar(255) not null, bar_dttm datetime not null, bar_open int not null, bar_close int not null ) </code>
Chciałbym zapytać o tabelę i zwrócić ostatnie 5 wierszy na instrument.
Mogę to zrobić za pomocą instrumentu, z:
<code>select top 5 instrument, bar_dttm, bar_open, bar_close from bar where instrument = 'XXX' order by bar_dttm desc </code>
Chciałbym to zrobić dla wszystkich instrumentów jednocześnie w jednym zapytaniu. czy to możliwe? Używam SQL Server 2008.