Multiple Records

General
Enthusiast

Multiple Records

Hello folks,

 

Please go through below Sql. This results in multiple records for single ID. Please suggest me how to get a single record. My result should be a single record for A and B for give conditions.

 

Sel T2.ID, Max(T2.A), Max(T2.B), T2.Effective_Date, T2.End_Date

from ABC T1

Inner Join XYZ T2

on T1.ID = T2.ID

and T1.Begin_Date between T2.Effective_Date and T2.End_Date

and T2.C = '1'

and T2.ID = '123'

group by 1,4,5

 

Thanks in advance.

1 REPLY
Teradata Employee

Re: Multiple Records

Hard to answer this without more information.

Are you saying that T1 has multiple rows with ID = 123?

If so, do all the rows have the same Begin_Date or are they different?

 

Perhaps you need an aggregate subquery, e.g.

Sel T2.ID, Max(T2.A), Max(T2.B), T2.Effective_Date, T2.End_Date

from (Select ID, max(Begin_Date) from ABC group by 1) T1

...