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

qualify rank() over (partition) - question - response (9) by gksenthilkumar

$
0
0

Sorry for late response, I tried but it didn’t work as expected and expecting below
create
table ppi (a int, b date, c int, d int);
 
insertinto ppi values (1, CURRENT_TIMESTAMP, 1,1);
insertinto ppi values (1, CURRENT_TIMESTAMP, 1,2);
insertinto ppi values (1, CURRENT_TIMESTAMP, 1,3);
 
insertinto ppi values (2, CURRENT_TIMESTAMP, 1,3);
insertinto ppi values (2, CURRENT_TIMESTAMP, 1,2);
insertinto ppi values (2, CURRENT_TIMESTAMP, 1,1);
 
select * from ppi qualify rank() over (partitionby a, c orderby b desc) = 1;
a              b                          c              d
1              2013-07-05           1              1
1              2013-07-05           1              2
1              2013-07-05         1               3
2              2013-07-05           1              3
2              2013-07-05           1              2
2              2013-07-05          1              1
 
select * from ppi qualify rank() over (partitionby a,c orderby b desc, d desc) = 1;
a              b                          c              d
1              2013-07-05           1              3
2              2013-07-05           1              3
Below is expected output what I need if I use like qry 1 (table has c1 to c100 other than a,b,c,d, but those c1 to c100 I just want to carry forward for selected rows and i don’t want to add in the partition with desc to avoid performance issue), any suggestion
 
a              b                          c              d
1              2013-07-05           1              3
2              2013-07-05           1              1


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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