I would like to generate an SQL query to achieve the following:
I have a table with columns A and B among others. I would like to get the sum for A and the sum for B (according to the WHERE clause I), as well as various other values. However, B may contain null values. I would also like to return, on the same query, the value of the sum A, for which the corresponding value of B is not null. This is the only return value I want to execute, regardless of whether B is null.
So, any suggestions on how I can achieve this? I work in SQL Server 2008.
Any help is much appreciated
source share