Good evening, gentlemen!
Please help ...
There is a table:
name status amount ----------------------- val1 1 45643 val2 2 32115 val3 1 46431 val4 2 23366 Please tell me how to select 2 columns in the select below, count the amount for status = 1 in one, and status = 2 in the second, the total amount is considered in the select. Is it possible to do the required calculation without nested selects?
select name, date, etc, wtf, sum(case when status !=1 then 1 else 0 end) as "2_count", sum(amount) as "all_amount" from foo, wtf, mega_table where /* over 9000 разных условий и связей тут */ Thank!