Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

self join - forum topic by aodabasio

$
0
0

I am making a mistake placing the self or left join. the main purpose of this querry is to bring back weekid, legid, avg final duration, volume, 95% of volume and 95th-tile of the avg duration.
I have the following code:
 

Select 

b. weekid, 

a.LegID, 

avg (Final_Duration) Avg_Final_Duration,

count(a.itemID) Volume,

cast (0.95 * Volume as integer) as Volume_95

from  table1 a

join table2 b

on a.receivedate=b.PeriodID

where 

a.Final_Duration  is not null

Left join (select avg(ts.final_duration)

 from  table1 ts

join table2 tm

on ts.receivedate=tm.PeriodID

where

ts.Final_Duration  is not null 

and

ts. X_tile >= 95 group by ts.LEGID, tm.WeekID) as Findur_95

group by  a.LegID, b.weekID

order by WeekID, a.LegID  ASC

 

please help!!! 

Forums: 

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>