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

Creating Group ID from SUM Limit - response (4) by saraider99

$
0
0

I tried to construct the query you recommended but when i ran it with over a hundred products it created almost as many buckets and didnt stick to the number of buckets i had wanted. I created another query using MOD and it gave me almost what i was looking for but didnt distribute as evenly as I had hoped for.

UPDATE main FROM prod_list AS main,  
(  
 SEL 
  PROD_NAME  
 ,  QTY_SOLD  
 ,  SUM(QTY_SOLD) OVER (ORDER BY NUMOF ROWS UNBOUNDED PRECEDING) RUNNING  
 FROM prod_list   
) inr 
SET GROUP_NBR = RUNNING MOD <# of buckets>
WHERE main.PROD_NAME = inr.PROD_NAME ;

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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