Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:59:52+00:00 2026-06-05T05:59:52+00:00

I just waste Two to Three Hourse behind This Sql Transact and confused on

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:59:54+00:00Added an answer on June 5, 2026 at 5:59 am

    Remove your GROUP BY clause:

    select
        max(case when a.catagory = 'Purchase Account' then l.name end) as PurchaseAccount,
        max(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 IN ('Purchase Account', 'Sales Account')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems something I shouldnt have to waste a question on, but I can't
Lets assume a table like this [KEY] [int] NOT NULL, [INT1] [int] NULL, [INT2]
Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
Just wanted to know if it is better to have Accept-Encoding, gzip in request
Just a quick check really. I have an XML file that I will be
just wanted to add this Color Picker ( http://code.google.com/p/devmil-android-color-picker/source/browse/ ) to my app and
I have a view that displays in a UIPopoverController. Before, it just had properties
I have two very large matrices (60x25000) and I'd like to compute the correlation
Here’s the thing. I have two keyboard layouts, ‘HR’ (Croatian, my native language) and
I have a query which is just a few times too slow but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.