I have a query that provides wrong results, am I doing something wrong in this query
SELECT b.nBoutiqueID, b.sbootName, b.Status, sum (bs.nViewCount) nViewCount, SUM (ps.nViewCount) nProductViewCount, SUM (ps.nLinkClickCount) nLinkClickCount, SUM (ps.nWishListCount) nWishListCount , SUM (ps. NReferredCount) from nReferredCount boutique B LEFT JOIN boutique_stats BS on Bn.BrickIDIDID = Bn Bucket IDIID Bucket join product_stats ps ps.nboutiqueID = b.nBoutiqueID WHERE B.Bridated = 0 Group B N. Bucketid By PN Order by producted DESC
is not making any errors, but presenting the wrong result. I'm using MySQL.
For the special example of nBoutiqueID = 1 the maximum amount of nViewCount should be 455, but it gives 9 5124. This is a lot of difference. Why do I know someone?
It appears that you are receiving a kind of cartesian product of the query. Try to get your SUM () value from the questions ...
SELECT b.nBoutiqueID, b.sbootname, b.Status, bs.StatsViewCount, ps.ProductViewCount, ps.ProductLinkClickCount , Ps.ProductWishListCount, ps.ProductReferredCount FROM Boutique B LEFT JOIN (select nBoutiqueID, by nBoutiqueID from the StatsViewCount boutique_state group as the amount (nViewCount) b.nBoutiqueID = bs.nBoutiqueID on the bs left (select SUM (nViewCount ) ProductViewCount, SUM (NLinkClickCount) Pr OductLinkClickCount, SUM (nWishListCount) ProductVisualistCount, SUM (nReferredCount) ProductReferredCount F Rob Product_stats by group nBoutiqueID) ps at ps.nboutiqueID = b.nBoutiqueID where b.bDeleted = 0 ORDER by ps.nProductID DESC
< / Div>
Comments
Post a Comment