Well cart was appearing empty dude to earlier test orders .
Your sql works awesomely. But Quantity not on proper product.
i added two product's batch in cart of same ProductID. But quantity ain't responding well in cart.
ProductBatch data attached. & also cart screenshot attached.
1 - BATCH: DSF234 Quantity : 500 it is valid in cart.
2 - BATCH: SNKFJ-12 Quantity: 123 it is not valid in cart. (displays 945)
3 - BATCH: XYZ Quantity : 945. (2,3 and same product but different batch products)