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

  • SEARCH
  • Home
  • 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 9226767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:54:32+00:00 2026-06-18T04:54:32+00:00

Scenario – We have pack items, which is defined as a composite of one

  • 0

Scenario –
We have pack items, which is defined as a composite of one or more items. A complex pack is a one that has more than one component items. Each component item of a complex pack item should be linked to equal number of locations.

For example:
Pack P1 has component C1, C2, and C3. Each item C1,C2 and C3 is ranged to 10 locations 1,2….10, such that C1-1,C1-2,…,C1-10,C2-1,C2-2,…,C2-10,and C3-1,C3-2,…,C3-10 exists. In such case the pack item P1 also gets associated to locations 1 through 10, as P1-1,P1-2,…,P1-10.

The table PACK_BREAKOUT contains the Pack component mapping and the table ITEM_LOCATION contains the items to location association. Both Pack and Component are considered as “items” and would exist in ITEM_LOCATION.

Ideally, for the a scenario like above the below record-set would be valid

PACK_NO    ITEM    NO_OF_LOC
--------   ------  -------------
P1         C1      10
P1         C2      10
P1         C3      10

I have the query below that returns result like above for all such pack items.

select c.pack_no,c.item,count(a.loc )
  from item_location a, pack_breakout c
 where c.item=a.item
   group by c.pack_no,c.item
   order by 1,2;

However, there are some discrepant results like pack no. P2 , P4, and P5 below where the components are not associated with equal number of locations.

PACK_NO    ITEM    NO_OF_LOC
--------   ------  -------------
P1         C1      10
P1         C2      10
P1         C3      10
P2         C1      11
P2         C2      5
P2         C3      9
P2         C4      11
P3         C1      21
P3         C2      21
P3         C3      21   
P3         C4      21
P3         C5      21
P4         C1      10
P4         C2      15
P5         C1      10
P5         C2      9
P5         C3      10
P5         C4      10

Note that a pack can have n-number of components (as you can see P1, P2, P3, P4, and P5 have different number of components).

I would like to get only the packs whose component locations are not all consistent. So the desired result set would be-

PACK_NO    ITEM    NO_OF_LOC
--------   ------  -------------
P2         C1      11
P2         C2      5
P2         C3      9
P2         C4      11
P4         C1      10
P4         C2      15 
P5         C1      10
P5         C2      9
P5         C3      10
P5         C4      10

Note that even if one component does not match no. of locations as the other components within the pack, the entire pack must be considered inconsistent (like P5).

  • 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-18T04:54:33+00:00Added an answer on June 18, 2026 at 4:54 am

    You want to use another group by with a having clause:

    select pack_no
    from (select c.pack_no, c.item, count(a.loc ) as numlocs
          from item_location a join
               pack_breakout c
               on c.item=a.item
          group by c.pack_no, c.item
         ) p
    group by pack_no
    having MIN(numlocs) <> MAX(numlocs)
    

    This returns the packs.

    If you want the details of the numbers, then use the analytic functions for the calculation:

    select pi.*
    from (select pi.*, min(numlocs) over (partition by pack_no) as minnumlocs,
                 max(numlocs) over (partition by packno) as maxnumlocs
          from (select c.pack_no, c.item, count(a.loc ) as numlocs
                from item_location a join
                     pack_breakout c
                     on c.item=a.item
                group by c.pack_no, c.item
               ) pi
         ) pi
    where minnumlocs <> maxnumlocs
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I have an application that has a config table which stores the config
Scenario: I have a TFS Build (TFS2008) that has several targets override: BuildNumberOverrideTarget, AfterGet,
Scenario: I have a text file that has pipe (as in the | character)
SCENARIO: I have a simple application that checks its RSS feed and looks if
Scenario: I have a page which contains a dropdownlist and a table which contains
Scenario: I have a php page in which I call a python script. Python
Scenario: I have a directory on a server that hosts my website that contains
Scenario: There is a complex piece of software that is annoying to launch by
Scenario: I have a blog that I want to make a post to. I
Scenario: In a Winform application(C#), I have a Datagridview in which I have to

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.