sql - Have two tables A,B that has one to many relationship. I want to link A to B by only taking the most recent instance in B -
I have two tables, A and B. For any particular column in A, there are several rows in B for a particular value that corresponds to it, I want to remove information from B, but not all the rows but most recently.
What is the best way to do this?
Thanks
A typical way to do this is ANSI standard row_number ( )
function. Here's the question of how a query might look: Select
Select from a left pair * (b. *, Row_number ()) (b.ate desc) as seqnum B) B a.aid = B.Ed and B. Sekuanum = 1;
You can also contact it with aggregation:
select * Join the left to join an a.aid = b.aid ( Select baid, Max (Baiduet) statements from Max) bmax at b.aid = b.aid and b.date = bmax.date;
Comments
Post a Comment