Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do join in Teradata

Status
Not open for further replies.

ktanmayi

Programmer
Mar 6, 2008
1
US
Hi,

1) I have 5 huge tables with disjoi1nt data columns except the PI and date column.I need to merge the data into one table so that, one row per account(PI) is created with individual data columns from the 5 tables. The accts may or maynot match between the tables. How do I do this without performance issues? LEFT JOIN?

2) I have a one-rowed table which has NUPI of run-date. Some data tables have acct-key as UPI and run-date as PPI.But some data tables have neither acct-key nor run-date columns. I might have to build join across tables-with-columns, tables-without-those-columns and the one-row table to evaluate data in CASE statements. EXPLAIN shows product join and is badly skewed. How can I rewrite this better?
Ex: T1(huge table with columns)
T2(huge table without columns)
SR(single row table)
sel
Sum(case
when T1.t1 = 'X' and
SR.code = ' ' and
T2.t2 = 'Y'
then 'GOOD ACCT'
end) as qualified_acct
from
T1, T2, SR
where
T1.acct-key = T2.acct-key and
T1.run-date = SR.run-date;




 
This may not be helpful, but did you turn on diagnostic stats and run the suggested collect statistics?

"Diagnostic Helpstats On for Session;"

Then run your explain, and at the bottom it should suggest statistic to collect to help optimize the query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top