SQL pour summary financier dans le SI
Révision datée du 27 février 2016 à 17:32 par Bruno (discussion | contributions) (Page créée avec « <pre> select valid_from, valid_until, dbegin_may, dend_may, (dend_may - dbegin_may + 1) as nb_days_may, value_day, nb_days, value_day * (dend_may - dbegin_may... »)
select valid_from, valid_until, dbegin_may, dend_may, (dend_may - dbegin_may + 1) as nb_days_may, value_day, nb_days, value_day * (dend_may - dbegin_may + 1) as value_may from (select valid_from, valid_until, greatest(valid_from, '2016-05-01') as dbegin_may, least(valid_until, '2016-05-31') as dend_may, price, price / (valid_until - valid_from) as value_day, valid_until - valid_from as nb_days from invoices_elts where valid_until >= '2016-05-01' and valid_from <= '2016-05-30') as may;