0
SELECT Sum(tblWarehouseItem.whiQty) AS Sum,
tblWarehouseItem.whiItemName
FROM tblWarehouseItem
WHERE tblWarehouseItem.whiActive =True 
AND tblWarehouseItem.whiCansel=False 
AND tblWarehouseItem.whiExpiryDate Is Null
GROUP BY tblWarehouseItem.whiItemName, tblWarehouseItem.whiQty

if you please help me i am confused...

i have the above Query.

For example in my table i have:

whiItemName   whiQty(sum)
Fuel          100
Fuel          100
Fuel          100

I wlould like the output to be:

whiItemName   whiQty(sum)
Fuel          300

2 Answers 2

4

You have an extra column in your GROUP BY

You just need:

SELECT Sum(tblWarehouseItem.whiQty) AS Sum,
tblWarehouseItem.whiItemName
FROM tblWarehouseItem
WHERE tblWarehouseItem.whiActive =True 
AND tblWarehouseItem.whiCansel=False 
AND tblWarehouseItem.whiExpiryDate Is Null
GROUP BY tblWarehouseItem.whiItemName
Sign up to request clarification or add additional context in comments.

Comments

0

The short of it is you need to remove the tblWarehouseItem.whiQty from the group by. I'm not sure what you are doing with the where condition but you also might try as a having keyword. The statement below will illustrate the point.

SELECT tblWarehouseItem.whiItemName, Sum(tblWarehouseItem.whiQty) AS Sum FROM tblWarehouseItem GROUP BY tblWarehouseItem.whiItemName

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.