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

Help with SQL - response (5) by dnoeth

$
0
0
Based on your narrative: SELECT test.*, CASE WHEN ROW_NUMBER() OVER (PARTITION BY col1,dt,col4 ORDER BY col3) = 1 THEN (dt-MIN(dt) OVER (PARTITION BY col1 ORDER BY dt,col4,col3 ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)) - CASE WHEN col3-MIN(col3) OVER (PARTITION BY col1 ORDER BY dt,col4,col3 ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) <= 0 THEN 1 ELSE 0 END END FROM testDieter

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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