2016-03-21 9 views
-2

私は製品のリストを持っています。私は注文のテーブルを検索し、いくつのバッチが生産されたのかをカウントしたいと思います。値のリストからレコードを数える方法

どうすれば実現できますか? 私はこのSQL命令を使用しており、製品のリストにあるすべてのバッチを見つけました。記事の名前でグループ化するにはどうすればよいですか?

Select articlename, articleqnty, articleuom from orders 
where articlename in (product1, product2, product3, etc...) 
+0

[Oracle group/count query](http://stackoverflow.com/questions/8492347/oracle-group-count-query)の重複している可能性があります。 –

答えて

0

あなたが総取得するarticleqntyを合計する場合:あなたはちょうどその行のカウントをしたい場合は

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

かを、:

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

したい場合は何か他のものであれば、あなたの質問を明確にして編集する必要があります。

関連する問題