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_totals. every order status_id > 65, add final_totals. 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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -