メール送信履歴を管理するテーブルで、メール1通につき、1レコードが作成されます。
このテーブルから店舗ごとの日次件数を取得したいのですが、方法がわかりません。
お教えいただけますでしょうか?
email_history
email_history
id numeric not null primary_key shop_id numeric message text created_date timestamp
shop
shop_id numeric not null primary_key name text
試したこと
with s as(select count(*), shop_id, created_date from email_history group by shopid) select count(*) from s group by created_date;
出現したエラー
column "created_date" must appear in the group by clause or be used in an aggregate function
created_dateをgroup byに含めてくださいと言っているのはわかったのですが
どのようにしたらよいのかわからず、お詳しい方、お教えくださいm(_ _)m
まだ回答がついていません
会員登録して回答してみよう