I have a view that generate the query result like below:
channel | current_Month | total_month_count | type | total_type_count |
-----------------------------------------------------------------------
chaA | 2 | 1 | N | 1 |
-----------------------------------------------------------------------
chaB | 2 | 2 | N | 2 |
-----------------------------------------------------------------------
chaA | 2 | 3 | Y | 3 |
-----------------------------------------------------------------------
I would like to make a query on the view that could retrieve the value of total_month_count of type 'Y' to minus the value of total_month_count of type 'N' under the same channel group. In this case, there are 2 rows will get affect which is row 1 and row 3, which will be 3 minus 1, and the result will be equivalent to 2.
How could I make a query that could return me the result of 2 base on this view in Informix? Lets not limit to Informix, any other DB will do, I'm just curious to know whether are there any solution to do it in SQL?