0

実際に機能するこのようなSQLステートメントを実行する方法:

select distinct store_id as myid, 
       (select count(*) from products where store_id = myid and delete_flag = true)     
from products 
where delete_flag = true 

すべてのストア ID と、このストア ID を持つ削除された製品の数を含む列が必要です。

4

2 に答える 2

3
select store_id, 
       count(*) as all_product_count,
       sum(case when delete_flag = 1 then 1 else 0 end) as deleted_product_count
from products     
group by store_id
于 2013-09-12T09:22:30.920 に答える
0

それが役に立てば幸い!

select store_id as myid , count(*) as noofdeleteditems from products where delete_flag = true group by store_id;
于 2013-09-12T09:28:08.173 に答える