Linked Questions

Popular Questions

sql select from table with date range condition

Asked by At

I have this table

CREATE TABLE `tarif` (                  
  `tarif_id` int(11) NOT NULL AUTO_INCREMENT,
  `start_tarif` date NOT NULL,
  `end_tarif` date NOT NULL,
  `day_tarif` varchar(50) NOT NULL,
  PRIMARY KEY (`tarif_id`)
);

INSERT INTO `tarif` VALUES (1, '2019-02-01', '2019-02-10', '10'),
                           (2, '2019-02-11', '2019-02-20', '20'),
                           (3, '2019-02-21', '2019-02-28', '10'),
                           (4, '2019-03-01', '2019-02-10', '15');

How can I get day_tarif between 2019-02-05 and 2019-02-15 and calculate the sum = day_tarif * number of date betwwen 2019-02-05 and 2019-02-15

Related Questions