|  |  | Archives of the TeradataForumMessage Posted: Fri, 24 Jun 2005 @ 22:10:29 GMT
 
 
  
| Subj: |  | Re: SQL to flattening a table |  |  |  | From: |  | Michael Larkins |  
 I think I would do this using a self-join and since not all will have 4 accounts, an outer join: 
     select a100.cust, a100.bal, a200l.bal, a300.bal, a400.bal
     from tb11 as a100 left join tb11 as a200 on a100.bal=a200.bal
                       left join tb11 as a300 on a100.bal=a300.bal
                       left join tb11 as a400 on a100.bal=a400.bal
     where a100.acct=100
       and a200.acct=200
       and a300.acct=300
       and a400.acct=400;
 Hope this helps, Michael LarkinsCertified Teradata Master
 Certified Teradata SQL Instructor
 
 
 |  |