May be this question is a duplicate of another, I already explored couple of similar questions here but I didn't find similar one. Please suggest if you find a link to similar question.
My problem is, I have a table say CLIENTS as below
BRANCH CLNTID ACCNT FACID
------ ---------- ---------- ----------
201 10001 123400 110021
201 10001 123401
201 10001 123402 110023
201 10001 123403
201 10001 123404 110025
201 10001 123405
201 10001 123406 110027
201 10001 123407 110028
so on... many rows. Now I want to write a query to give output like this
Branch clntid facid_null facid_not_null
201 10001 3 5
I want to find facid colmun count for facid=null and facid !=null for each branch and each clntid.
I wrote the below query but its fetching only one count either facid is null or facid is not null.
select branch,clntid,count(*)
from clnt
where facid is null
group by branch, clntid;
Please help me to find both counts in a single query using GROUP BY and as well as OVER (PARTITION BY ) clauses.
Thanks in advance. Vivek.