Hi all, I have this query that work fine SELECT products.product_id, (SELECT SUM(quantity) FROM transactions WHERE transactions.product_id = products.product_id AND transactions.flow = 1) AS loaded, (SELECT SUM(quantity) FROM transactions WHERE transactions.product_id = products.product_id AND transactions.flow = 0) AS unoaded FROM products WHERE products.enable = 1
but when I try to make this SELECT products.product_id, (SELECT SUM(quantity) FROM transactions WHERE transactions.product_id = products.product_id AND transactions.flow = 1) AS loaded, (SELECT SUM(quantity) FROM transactions WHERE transactions.product_id = products.product_id AND transactions.flow = 0) AS unoaded, SUM(loaded - unloaded) AS stock FROM products WHERE products.enable = 1 I get the following error message no such column: loaded Any suggestion about the right syntax? regards Beppe _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

