sql - MySQL Query - 2 Sums, added together -
i have table (orders) this:
id sub_total final_total status_id date_estimated
i'm looking following: every order status_id = 65
, add sub_total
s. every order status_id > 65
, add final_total
s. then, take both sums, add them together, , return new sum.
is possible in 1 query? had following, doesn't account new final_total
functionality:
"select sum(sub_total) total orders month(date_estimated) = month(curdate() - interval 1 month) , status_id = 65"
nevermind date stuff in query.
select sum(sub_total) total orders month(date_estimated) = month(curdate() - interval 1 month) , status_id = 65 union select sum(final_total) total orders month(date_estimated) = month(curdate() - interval 1 month) , status_id > 65
Comments
Post a Comment