Can i read interval value from another column in database

Viewed 829

I have a table with (custid,purchase_timestamp (dd-mm-yyyy), warranty_period) in days. I need the sum of purchase_time and warranty_period.How can i write SQL for this.

I tried

SELECT DATE_SUB(purchase_timestamp, INTERVAL warranty_period DAY); 

but it does not work. Please suggest

 |custid |    warranty_period  |   purchase_timestamp
    |1        |      365            |   03-01-2017  
    |2        |      30             |   03-04-2017
    |3        |     10              |   25-05-2017
    |4        |      30             |   20-05-2017
    |5        |     365             |   04-06-2017
    |6        |     100             |   18-06-2017
    |7        |     90              |   30-06-2017
    |8        |     10              |   05-07-2017
    |9        |        30           |   09-07-2017
    |10       |     365             |   17-07-2017
2 Answers
Related