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

Help needed on recursive sql - forum topic by dr.murthy_td

$
0
0

Hi , 
 
i have an table its having four fields cost,retail,units,weekdayyr. sample data is given below.

cost,retail,units,weekdayofyr

120,125,100,1

115,132,142,1

114,859,236,2

114,158,258,2

147,258,639,3

 

i need a sequel to that generate summation of the fields by groupng on week also total item cost would be the sum of three fields (tot_cost,tot_retail,tot_units) . here i need value of 1st week total item cost as in the field prv_wk_item_cost on 2nd record, look at the required output.

 

prv_wk_item_cost,tot_cost,tot_retail,tot_units,weekdayofyr

0,235,257,242,1

734,228,1017,494,2

1729,114,158,258,2

 

prv_wk_item_cost = previous week(tot_cost + tot_retail + tot_units).
 
Appreciable your 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>