简体   繁体   中英

How to summarize two tables in teradata

I have the following two tables

在此处输入图片说明

I need to create a table that would summarize points for each date

在此处输入图片说明

How can I do this . I have updraded to Teradata 14 . And I am not quite familiar with all the new functions

If table1 is actually only a few rows you don't need any fancy query.

Assuming table1.caseid is a byteint this will result in a product join:

Select t2.datex, t2.caseid, sum(t1.points)
from table1 as t1 join table2 a t2 
on position(trim(t1.caseid) in t2.caseid) > 0
group by 1,2

Of course if this was a properly normalized table you could simple use a t1.caseid = t2.caseid join instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM