xander85 Posted February 16, 2008 Share Posted February 16, 2008 Hi All, I am trying to sum three subselects and return a single value; however, if any of the three returns AS null then the value is NULL. How can I change my statement so if any are null they simply add as 0? Here is my code (the id, site_id, and workid numbers are simply for reference) select (sum(work_orders.unitprice * work_orders.qty) + (SELECT sum((expenses.markup * expenses.total)*expenses.qty) from expenses where expenses.id = 15 AND expenses.workid = 3 AND expenses.site_id = 5) + (select SUM(dist*.485) from mileage where id = 15 and site_id = 5 and workid = 3 AND billed = 1 GROUP BY id AND site_id AND workid)) as total from work_orders where work_orders.id = 15 and work_orders.site_id = 5 and work_orders.workid = 3 GROUP BY work_orders.id AND work_orders.site_id AND work_orders.workid Quote Link to comment Share on other sites More sharing options...
xander85 Posted February 16, 2008 Author Share Posted February 16, 2008 Figured it out. I wasn't using IFNULL correctly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.