Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Take Distinct Key and join Flags from non-distinct

Basically I want to take a table like this:

keyflag1flag2flag3
1100
1001
1010
2000
2010
2001

and make another table like this, that is only the distinct keys with flags joined to it:

keyflag1flag2flag3
1111
2011

I think there's an easy way to do this but I'm kind of slow today. Any help would be appreciated.

Thanks!

1 Solution

Accepted Solutions
jpapador
Partner - Specialist
Partner - Specialist

If a row can never have a 1 in multiple flags you could Sum the flag fields and group by Key

TableName:

LOAD

      Key,

      Sum(Flag1) as Flag1,

      Sum(Flag2) as Flag2,

      Sum(Flag3) as Flag3

Resident data

Group By Key;

View solution in original post

3 Replies
jpapador
Partner - Specialist
Partner - Specialist

If a row can never have a 1 in multiple flags you could Sum the flag fields and group by Key

TableName:

LOAD

      Key,

      Sum(Flag1) as Flag1,

      Sum(Flag2) as Flag2,

      Sum(Flag3) as Flag3

Resident data

Group By Key;

Anonymous
Not applicable
Author

Hi,

Table1:

LOAD

      Key,

      Count(Flag1) as Flag1,

      Count(Flag2) as Flag2,

      Count(Flag3) as Flag3

Resident Table

Group By Key;

Not applicable
Author

Thanks!