[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

SQL Join Query Issues

Asked by pmessana in PHP Scripting Language, SQL Query Syntax, MySQL Server

Tags: SQL

I have a query that I am having problems with.  

The problem is that table d (quantity_map) can have two rows with the same qbpos_id, thus when it does the conditional IF statement it will add the quantity twice if there are two rows and three times if there are three rows.

The data is correct and it is possible for there to be multiple rows so I need to account for that but I cannot think of a good way to handle this, I thought about doing sub query to remove the duplicates and get it to be distinct but I figured there has to be an easier way.

For example purposes of what I mean by this.

ProdID 101 has qbpos_id of 5000
ProdID 455 has qbpos_id of 5000

The ProdID does not matter for determining the Quantity on Hand, only the qbpos_id matters since the underlying product is identical.  However, when it does the SUM it will sum ProdID 101 and ProdID 455 together effectively saying that twice as much inventory of qbpos_id 5000 exists, when it doesn't.

This is complicated and I am sure someone will tell me that it is a flaw in the data model but ProdID is our online product ID and qbpos_id is what the online product is mapped two and for SEO and Search purposes we double list the product with different names and map to the back-end product.

So, for those of you that understand the problem do you have any idea on how I can write the below query to select the information for DISTINCT qbpos_id's?  Can I change it into a JOIN and do some sort of DISTINCT clause in a JOIN????  I couldn't find anything about this.

I am running MySQL 5.

Thanks in advance, I am assigning 500 points but wish I could do much more....this one has me stumped and I am sure is confusing enough to warrant more.



SELECT *, e.ProdID, b.Descr, b.Size, b.Attribute, b.ItemNumber, auxMinimumQty, SUM(IF(StoreID='6',QuantityOnHand,0)) AS AUX, SUM(IF(StoreID='1',QuantityOnHand,0)) AS BRK, IF(auxMinimumQty-(SUM(IF(StoreID='1',QuantityOnHand,0)))>=SUM(IF(StoreID='6',QuantityOnHand,0)),'N','Y') as ENOUGH, c.ListID

FROM  item_inventory b, item_store_inventory c, quantity_map d, products e

WHERE d.qbpos_id=b.ItemNumber
AND b.ListID=c.ListID
AND d.prodid=e.prodid
AND e.deleted='N'
AND StoreID IN (1,6)
AND e.prodid

GROUP BY b.ItemNumber

HAVING AUX<auxMinimumQty AND BRK!=0 AND auxMinimumQty>0

ORDER BY ENOUGH desc, BayNumber, ShelfNumber, ShelfPosition
[+][-]11/05/09 01:55 PM, ID: 25754486Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 02:19 PM, ID: 25754718Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 02:29 PM, ID: 25754811Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 07:33 PM, ID: 25756407Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 12:42 AM, ID: 25757568Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 05:42 AM, ID: 25758941Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 05:53 AM, ID: 25759049Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 05:56 AM, ID: 25759073Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 06:07 AM, ID: 25759175Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 06:16 AM, ID: 25759256Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 06:24 AM, ID: 25759312Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 06:28 AM, ID: 25759354Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 07:04 AM, ID: 25759667Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 07:08 AM, ID: 25759712Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 07:20 AM, ID: 25759837Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 07:52 AM, ID: 25760159Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 07:57 AM, ID: 25760229Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: PHP Scripting Language, SQL Query Syntax, MySQL Server
Tags: SQL
Sign Up Now!
Solution Provided By: agnomie
Participating Experts: 3
Solution Grade: A
 
[+][-]11/06/09 08:15 AM, ID: 25760428Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 08:19 AM, ID: 25760459Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 08:20 AM, ID: 25760471Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 08:36 AM, ID: 25760626Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/06/09 08:49 AM, ID: 25760762Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/06/09 08:57 AM, ID: 25760852Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625