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 9019455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:46:53+00:00 2026-06-16T04:46:53+00:00

I have a sql that is as under: SELECT ib.branch_no, ib.on_hand, p.weightedav, p.item_code, FROM

  • 0

I have a sql that is as under:

SELECT ib.branch_no,
       ib.on_hand,
       p.weightedav,
       p.item_code,
FROM physical p
INNER JOIN 
       item_branch as ib on p.item_code = ib.item_code
WHERE ib.on_hand <> 0

This SQL returns only those branch_no that have on_hand <> 0.

I am trying to get all the branch_nos irrespective of the on_hand field, but while still using the where on_hand clause.

Taking the on_hand clause away solves my problem, but gives me large amount of un-needed rows with 0’s.

I am using SQL SERVER 2008 R2.

Thanks in advance for any guidance. Please apologize if I am missing any information.

——————————————ENTIRE SQL QUERY (Updated)———————————————

select  
     ib.branch_no, 
    p.weighted_av,
    p.item_code, 
    p.x_value, 
    p.y_value, 
    ib.on_hand,
    p.on_hand as PhysicalOH,
    ip.price,
    i.item_code as StyleCode, 
    i.description, 
    i.cat1, 
    i.cat2, 
    i.cat3, 
    i.cat4, 
    np.is_style_yn, 
    si.supplier_code ,
            ysv.sort as YSort
from physical  as p
    left outer JOIN 
    item_branch as ib on p.item_code = ib.item_code -- and ib.on_hand <> 0
    INNER JOIN 
    item_price as ip on p.item_code = ip.item_code  and ip.price_type = 'P1'
    INNER JOIN 
    style_values as sv on p.style_code = sv.style_code and p.x_value = sv.value  
    INNER JOIN 
    style_values as ysv on p.style_code = ysv.style_code and p.y_value = ysv.value and ysv.axis = 'Y'  
    INNER JOIN 
    ITEM as i on p.style_code = i.item_code 
    INNER JOIN 
    NON_PHYSICAL as np ON i.item_code = np.item_code and np.is_style_yn = 1
    INNER JOIN 
    supplier_item as si ON i.item_code = si.item_code and si.pref_supp_no = 1
where --ib.on_hand <> 0 and  
sv.axis = 'X' and
i.item_code in 
    (SELECT ITEM.item_code
     FROM ITEM 
            INNER JOIN 
            NON_PHYSICAL ON ITEM.item_code = NON_PHYSICAL.item_code 
            LEFT JOIN
            supplier_item ON Item.item_code = supplier_item.item_code  and  pref_supp_no = 1                        
    WHERE NON_PHYSICAL.is_style_yn = 1 and  ITEM.cat1 = 'Verge Sportswear Ltd' )
order by 
        si.supplier_code, 
        i.cat4, 
        i.cat3, 
        i.cat2, 
        i.cat1,
        sv.sort
  • 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-16T04:46:54+00:00Added an answer on June 16, 2026 at 4:46 am

    Try this:

    SELECT ib.branch_no,
           ib.on_hand,
           p.weightedav,
           p.item_code,
    FROM physical p
    INNER JOIN 
           item_branch as ib on (p.item_code = ib.item_code AND ib.on_hand <> 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sql that is made by help of others. $sql = select
I have this SQL Query that pulls data from 3 tables. I am unable
I have a query that looks like this: SELECT OrganizationName, OrganizationID, ReceivableStatus, InvoiceFee FROM
I have a SQL query that returns a Datatable: var routesTable = _dbhelper.Select(SELECT [RouteId],[UserId],[SourceName],[CreationTime]
I have a select from (nothing to complex) Select * from VIEW This view
I have this SQL query, and directly under it, another query based on the
I have this massive query that I can typically run in under 2 minutes.
Currently i have this procedure under package that gets user_name when some selects user_id
I have an interface that I want to allow an arbitrary SQL select statement
I have an SSIS package that I've saved under Maintenance Plans on SQL Server

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.