I just waste Two to Three Hourse behind This Sql Transact and confused on Null Value Skip.
I have two table like below:
Table 1: AccountMast
companyID accname category
102 PURCHASE ACCOUNT Purchase Account
102 SALES ACCOUNT Sales Account
Table2: Legder
companyID name
102 PURCHASE ACCOUNT
102 SALES ACCOUNT
I have join it as below:
select
case
when a.catagory='Purchase Account' then
l.name
end as PurchaseAccount,
case
when a.catagory = 'Sales Account' then
l.name
end as SalesAccount
from ledger l join accountmast a
on l.companyID=a.companyID
and l.name = a.accname
where l.companyID=102
and a.catagory='Purchase Account' or a.catagory='Sales Account'
group by l.name,a.catagory
The Result is:
PurchaseAccount SaleAccount
PURCHASE ACCOUNT NULL
NULL SALES ACCOUNT
But I Want Result Like:
PurchaseAccount SaleAccount
PURCHASE ACCOUNT SALES ACCOUNT
How to Do It?
Remove your
GROUP BYclause: