SQL: Use distinct on groups of similar data -


hello mates have following problem in vertica database: have large table

+------+------+------+ | date | col1 | col2 | +------+------+------+ |    1 |    | b    | |    2 |    | b    | |    3 | d    | e    | |    2 | c    | d    | |    1 | c    | d    | +------+------+------+ 

as can see have redundant data, taken on different dates (row 1 & 2 , row 4 & 5). table removes redundant data deleting rows lower date, giving me result that:

+------+------+------+ | date | col1 | col2 | +------+------+------+ |    2 |    | b    | |    2 | c    | d    | |    3 | d    | e    | +------+------+------+ 

using distinct not work since delete rows randomly not considering date, might end table this:

select distinct col2, col3 table    +------+------+------+ | date | col1 | col2 | +------+------+------+ |    2 |    | b    | |    1 | c    | d    | |    3 | d    | e    | +------+------+------+ 

which not desired.

is there anyway accomplish that? mates

do group by on 2 columns , aggregate on highest date:

select max(date), col1, col2 table group col1, col2 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -