Back to back dates result

Database
Enthusiast

Back to back dates result

Please help me with below sceanerio

Product_no    start_date             end_date

ABC              2015-07-29            2015-08-18

ABC              2015-08-19            2015-09-08

ABC              2015-08-19            2015-09-08

ABC              2015-09-30            2015-10-20

There is a product(ABC) which is on promotion from 2015-07-29 to 2015-08-18. From the next day i.e, 2015-08-19 another promotion has started. I want to find all the products which are having back to back promotions in a table. 

result: 

Product_no    start_date             end_date          

ABC              2015-07-29            2015-08-18    

ABC              2015-08-19            2015-09-08   


1 REPLY
Enthusiast

Re: Back to back dates result

This problem is easy if you use a derived period.  It allows you to use a plethora of period specific functions to answer questions just like this. Check out the TD documentation  http://www.info.teradata.com/HTMLPubs/DB_TTU_13_10/index.html#page/SQL_Reference/B035_1145_109A/Peri... or this post https://developer.teradata.com/database/articles/exploring-teradata-13s-period-data-type

You dont' have to have temporal turned on to use the Period data type or its' functionality.

cheers