vendredi 3 juillet 2015

sqlite query gives near "(": syntax error:

select returnAndFactory.returned_product_id as returned_product_id,returnAndFactory.returned_packing_id as returned_packing_id, returnAndFactory.return_type as return_type,returnAndFactory.quantity,preorderNewOrder.quantity, coalesce(returnAndFactory.quantity,0)coalesce(preorderNewOrder.quantity,0) as quantity from
(select return.returned_packing_id,return.returned_product_id,return.return_type,return.quantity-factory.quantity as quantity from(select shopReturnTable.returned_product_id,shopReturnTable.returned_packing_id, shopReturnTable.return_type,shopReturnTable.returned_quantity,sum(shopReturnTable.returned_quantity) as quantity
from shopReturnTable group by shopReturnTable.returned_packing_id,shopReturnTable.returned_product_id,shopReturnTable.return_type) as return left join
(select retToFacTable.returned_product_id,retToFacTable.returned_packing_id,retToFacTable.return_type,retToFacTable.returned_quantity,sum(retToFacTable.returned_quantity) as quantity
from retToFacTable group by retToFacTable.returned_packing_id,retToFacTable.returned_product_id,retToFacTable.return_type) as factory on return.returned_product_id = factory.returned_product_id and return.return_type = factory.return_type or return.returned_packing_id = factory.returned_packing_id) as returnAndFactory left join (select preorder.product_id,preorder.newQuant-orderNew.quantity as quantity from (select newTable.product_id,sum(newTable.quantt)as newQuant from (select preorderTable.product_id,preorderTable.packing_id,preorderTable.run,preorderTable.quantity,sum(preorderTable.quantity),size,size * sum(preorderTable.quantity) as quantt from preorderTable,packingTable where run="true" and preorderTable.packing_id = packingTable.id and preorderTable.product_id = packingTable.product_id group by preorderTable.product_id,preorderTable.packing_id) as newTable group by newTable.product_id) as preorder, (select product_id,sum(quantity) as quantity
from orderNewQuantityTable,shopTable
where shopTable.completed = "true"
and shopTable.id = orderNewQuantityTable.shop_id group by orderNewQuantityTable.product_id) as orderNew where orderNew.product_id = preorder.product_id) as preorderNewOrder on preorderNewOrder.product_id = returnAndFactory.returned_product_id and returnAndFactory.return_type = "full_bottle" order by return_type

Aucun commentaire:

Enregistrer un commentaire