sql - Selecting the newest records for 6 unique columns -


i have table of 6 currency conversions, it's updated daily. unfortunately way software works inserts new rows rather updating existing ones. previous select follows

select from_currency_id, xchg_rate  ( select top 6 from_currency_id, xchg_rate  shared_currency_exchange  not from_currency_id = 'cad'  order record_created desc ) t  order from_currency_id 

the issue records got updated while others didn't query returns duplicate values 1 of currencys , nothing one. need output 6 unique from_currency_ids , xchg_rate newest record_created dates

i've been trying group exclude duplicate rows no luck.

with x  (select row_number() over(partition from_currency_id order record_created desc) rn, * shared_currency_exchange) select from_currency_id, xchg_rate x  rn = 1 

this gives recent record rownumber 1 , can use cte condition.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -