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

find the min & max value for the below query - forum topic by Gowtham

$
0
0

I need your help to find the result for the below table

pil1              pil2         timp     Mdat              inti
3Week    3Month    1Year    9/27/2013        40
1Week    1Month    1Year    9/27/2013        40
1Week    1Month    6Month    3/27/2013        42
1Week    1Month    2Week    10/11/2012    44
1Week    1Month    9Month    6/27/2013        45
1Week    1Month    1Month    10/27/2012    46
1Week    1Month    Overnight    9/27/2012      47
1Week    1Month    3Month    12/27/2012    43
1Week    1Month    1Week    10/4/2012        41
1Week    8Month    1Year    9/27/2013        40

 
expected result is

 
pil1           pil2           timp         Mdat            inti
1Week    1Month    1Week    10/4/2012        41
1Week    1Month    1Month    10/27/2012    46
3Week    3Month    2Week    10/11/2012    44
3Week    3Month    3Month    12/27/2012    43
1Week    8Month    1Week    10/4/2012        41
1Week    8Month    1Year    9/27/2013        40

 
compare pil1 with timp,
if it is matched then put its mdat and inti value
if not matched then find the minimum value for that, for instance 2Week is smaller than 3week
so put 2week's mdat and inti values.
 
compare pil2 with timp,
if it is matched then put its mdat and inti value
if not matched then find the Maximum value for that, for instance 1year is higher than 8month
so put 1year's mdat and inti values.

 

Tags: 
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>