実際に機能するこのような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 を持つ削除された製品の数を含む列が必要です。
実際に機能するこのような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 を持つ削除された製品の数を含む列が必要です。
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
それが役に立てば幸い!
select store_id as myid , count(*) as noofdeleteditems from products where delete_flag = true group by store_id;