I have this table for examples:
id cp base qta data_in
1 0 BaseBianca 30 2015-02-01 13:09:55
2 0 BaseBianca 32 2015-01-10 13:38:58
3 0 BaseBianca 45 2015-01-05 13:55:09
4 0 BaseBianca 34 2015-01-15 13:55:19
5 0 BaseBianca 46 2015-01-01 13:56:53
6 0 BaseGialla 45 2015-01-05 14:17:05
7 0 BaseNera 33 2015-02-06 14:17:34
and i would like to obtain the total qty of base in every month. this is my sqlite query:
select base, strftime('%m', data_in), sum(qta) as total from tb_basi group by base
but this is the return:
base month qta
BaseBianca 01 187
BaseGialla 01 45
BaseNera 02 33
but the correct return table are
base month qta
BaseBianca 01 157
BaseGialla 01 45
BaseNera 02 33
BaseBianca 02 30
how can modify the query?
Aucun commentaire:
Enregistrer un commentaire