SQL category is in the returned data when no data is for that Category.

Hello Experts Exchange
I have a query that brings back a category and a sum value.

Here is my query.

Select Cat_Level2,Sum(TTL)
from V_SALES
where CS_WEEK = 24 and CS_YEAR = 2015
and LOC_Name = 'ABERDEEN, HOLBURN STREET'
and Cat_Level2 in ('WOMENSWEAR','MENSWEAR',
'CHILDRENSWEAR','Footwear Accessories')
Group by Cat_Level2
Order by Cat_Level2

Open in new window


I have four categories they are 'WOMENSWEAR','MENSWEAR','CHILDRENSWEAR', & 'Footwear Accessories'.  But there is no data for 'CHILDRENSWEAR', & 'Footwear Accessories' but I want them to come back and say zero instead of not appearing in my query results.

How do I do this on Oracle?

Regards

SQLSearcher
SQLSearcherAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
SELECT x.cat_level2, SUM(ttl)
    FROM (SELECT 'WOMENSWEAR' cat_level2 FROM DUAL
          UNION ALL
          SELECT 'MENSWEAR' FROM DUAL
          UNION ALL
          SELECT 'CHILDRENSWEAR' FROM DUAL
          UNION ALL
          SELECT 'Footwear Accessories' FROM DUAL) x
         LEFT JOIN v_sales
             ON cs_week = 24
            AND cs_year = 2015
            AND loc_name = 'ABERDEEN, HOLBURN STREET'
            AND cat_level2 = x.cat_level2
GROUP BY x.cat_level2
ORDER BY x.cat_level2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SQLSearcherAuthor Commented:
Thank you for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.