Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

OLAP-Unbounded Following query - forum topic by Sai088

$
0
0

Hi all,
 
what is the difference between the follwing queries
1) select product_id,sales_date,daily_sales,min(daily_sales)
 over(partition by product_id  order by daily_sales   rows between current row and unbounded following ) from sales_table where product_id=1000 ;
Result set is...
    product_id sales_date    DAILY_SALES    Remaining Min(DAILY_SALES)
1    1,000    10/3/2000    64,300.00    64,300.00
2    1,000    10/4/2000    54,553.10    54,553.10
3    1,000    9/29/2000    54,500.22    54,500.22
4    1,000    9/28/2000    48,850.40    48,850.40
5    1,000    10/1/2000    40,200.43    40,200.43
6    1,000    9/30/2000    36,000.07    36,000.07
7    1,000    10/2/2000    32,800.50    32,800.50

2) select product_id,sales_date,daily_sales,min(daily_sales)
 over(partition by product_id  order bydaily_sales Desc  rows between current row and unbounded following ) from sales_table where product_id=1000 ;
   Result set is..
     product_id    sales_date    DAILY_SALES    Remaining Min(DAILY_SALES)
1    1,000    10/2/2000    32,800.50    32,800.50
2    1,000    9/30/2000    36,000.07    32,800.50
3    1,000    10/1/2000    40,200.43    32,800.50
4    1,000    9/28/2000    48,850.40    32,800.50
5    1,000    9/29/2000    54,500.22    32,800.50
6    1,000    10/4/2000    54,553.10    32,800.50
7    1,000    10/3/2000    64,300.00    32,800.50

when i am excuting second one i am getting desired result set....
when using unbounded following only i facing this..
 
thanks,
Sai

 

Forums: 

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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