db.define_table('pedidos',
Field('fecha', type='date' ),
Field('cliente', ),
Field('pares', ),
Field('estado', ),
Field('noitems', ),
Field('notapedido', ),
Field('tipopedido', ),
Field('vendedor', ),
)
db.define_table('itemspedidos',
Field('NUM_ITEM', 'integer'),
Field('COD_PEDI', 'integer'),
Field('COD_CLIE', ),
Field('OD_SUCU' ),
Field('TIP_PEDI', ),
Field('TIP_BASE', ),
Field('COD_REFE', ),
Field('COD_COLO', ),
Field('CAN_PEDI', 'integer' ),
Field('CAMPO_01', 'integer' ),
Field('CAMPO_02', 'integer' ),
Field('CAMPO_03', 'integer' ),
Field('CAMPO_04', 'integer' ),
Field('CAMPO_05', 'integer' ),
Field('CAMPO_06', 'integer' ),
Field('CAMPO_07', 'integer' ),
Field('CAMPO_S1', 'integer' ),
Field('CAMPO_S2', 'integer' ),
Field('CAMPO_S3', 'integer' ),
Field('CAMPO_S4', 'integer' ),
Field('CAMPO_S5', 'integer'),
Field('CAMPO_S6', 'integer'),
Field('CAMPO_S7', 'integer' ),
Field('CAN_DOCE', 'integer' ),
)
I need to find pedidos by month using pedidos.fecha and to count how many itemspedidos.COD_REFE are per month by each itemspedidos.COD_REFE which is the item reference.