Combining multiple rows into a single row

Database
Teradata Employee

Combining multiple rows into a single row

Hi All,

This may have come up before but I'm not getting the answers that I'm seeking for, so I'm going to start a new thread here.

Here's the problem:

I have a table that stores customer info, let's call it Cust.

The table is loaded by an external process and sometimes it will produce multiple rows.

Eg:

Cust_Id   Name   Age   TelNo  Address1 Address 2

1             ABC      19      ?         ?                ?

1             ABC                ?        AAAAA         BBBBB

1             ABC      ?       1111    ?                ?

In order to avoid multiple rows being selected, I'm trying to write a post-load process that will select rows from this table, and merge the information into a single row , and the expected result should be this:

Cust_Id   Name   Age   TelNo  Address1 Address 2

1             ABC       19      1111   AAAAA    BBBBB

Can anyone help to point me to the right direction to get this working? I have been looking at various solutions but none seems to be working as expected. Appreciate the help.

2 REPLIES
Teradata Employee

Re: Combining multiple rows into a single row

SELECT cust_id, name, max(age),max(telno),... GROUP BY cust_id, name;

Hopefully there is some way to identify which rows are new so that these don't get coalesced with prior rows for a customer (eg an effective date).

Teradata Employee

Re: Combining multiple rows into a single row

Thanks Todd!

It helps to push me to the correct direction. Some more work ahead but at least I can progress now. Thanks again.