Reputation: 3980
I need to do a very simple select sum on orders table but its bringing back count of 82 locations when their is only one location for the first data
SELECT Orders.OrderNumber, sum(Orders.Location)
FROM ORDERS
GROUP BY Orders.OrderNumber,Orders.Location
What am I missing in such a basic query ?
Upvotes: 1
Views: 146
Reputation: 28403
You don't need Orders.Location in Group By Clause
Try this
SELECT Orders.OrderNumber, sum(Orders.Location)
FROM ORDERS
GROUP BY Orders.OrderNumber
Upvotes: 0
Reputation: 10780
You need to remove the Group By on Location:
SELECT Orders.OrderNumber, Sum(Orders.Location) AS SumOfLocation
FROM Orders
GROUP BY Orders.OrderNumber;
Upvotes: 4