1 2 3 4 5 6 | SELECT SUM ( CASE WHEN dt >= DATE_ADD( current_date , INTERVAL -30 DAY ) THEN qty END ) qty_30 , SUM ( CASE WHEN dt >= DATE_ADD( current_date , INTERVAL -60 DAY ) THEN qty END ) qty_60 , SUM ( CASE WHEN dt >= DATE_ADD( current_date , INTERVAL -90 DAY ) THEN qty END ) qty_90 FROM t WHERE dt >= DATE_ADD( current_date , INTERVAL -90 DAY ) ; |