-2

I have a list of products and I would like to search into the order's table and count how many batch had been produced.

How can I achieve that? I'm working with this SQL instruction and I found all the batches of the products in the product's list. How can I count them, grouping by article name?

Select articlename, articleqnty, articleuom from orders
where articlename in (product1, product2, product3, etc...)
Haldir87
  • 355
  • 1
  • 6
  • 16

1 Answers1

0

If you want to sum the articleqnty to get a total then:

Select articlename,
       SUM( articleqnty ) AS total_qnty
from orders
where articlename in (product1, product2, product3, etc...)
group by articlename;

or, if you just want a count of the rows then:

Select articlename,
       COUNT(1) as num_articles
from orders
where articlename in (product1, product2, product3, etc...)
group by articlename;

If you want something else then you will need to edit your question with a clarification.

MT0
  • 143,790
  • 11
  • 59
  • 117