SQL Server, cross-apply, and DISTINCT -


i had earlier problem cross apply, solved nicely (using cross apply).

here part. want 1 newest cardata row (all columns!) cars have new line within 24 hours. assume, first select should distinct carindexes cars have updated events within 24 hours, , second select gives newest row. anyhow dont know put distinct word properly, list of carindexes instead of cardata rows using query:

select distinct cd.carindex [dvm_data].[dbo].[cardata] cd  cross apply (   select top 1 * [dvm_data].[dbo].[cardata] carindex = cd.carindex order id desc) md cd.datetimeoccurred > (getdate()-1) 

so, how make distinct , whole rows work?


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -