Srihari
Srihari

Reputation: 2429

MS-Access - You tried to execute that does not include the specified expression 'Quantity' as part of an aggregate function

I tried to form a new query table that contain products, product quantity, Total Product Price, Price per Product, Am getting this error "You tried to execute that does not include the specified expression 'Quantity' as part of an aggregate function".

My Product Table Contains

UniqueNo ProductId   productName   Each  Qty TotalAmount
1        P101        Pen-Turbo     40    2   80
2        P102        NoteBook      150   1   150
3        P103        Scale         10    3   30
4        p102        NoteBook      150   1   150
5        p101        Pen-Turbo     40    1   40

Now i need to get that product sold out details that is

ProductId  Productname  Qty  Total Each
P101       Pen-Turbo    3    120   40
P102       NoteBook     2    300   150
P103       Scale        3    30    10

I tried this query but getting error SELECT ProductId, Product, Qty(SUM) FROM NewInvoice_2 GROUP BY ProductId, Product

Help me to obtain like that. Thanks in advance

Srihari

Upvotes: 0

Views: 509

Answers (1)

Ravinder Reddy
Ravinder Reddy

Reputation: 24012

SELECT 
  ProductId, Product, 
  SUM( Qty ) Qty, 
  SUM( TotalAmount ) total  
FROM NewInvoice_2 
GROUP BY ProductId, Product

Upvotes: 1

Related Questions