使用Mysql ---我必须得到每月反馈记录等于零的提供商数量,我不知道如何构建这个问题来搜索谷歌 我有7个表主题,与会者,反馈,日期,学生,分支,提供商,以下给出了这些表的模型
**feedback**:
id - 12
attendee_id - 32
comment - good learning from him
created - 2012-03-08 01:12:46
**attendee**:
id - 32
student_id - 345
topic_id - 128
created - 2014-01-07 07:50:38
class - topic
**student**:
id - 345
branch_id - 56
created - 2012-07-11 09:47:35
**provider**:
id - 67
name - narik
created - 2010-01-19 01:30:58
**branch**:
id - 56
name - vize creators
provider_id - 67
created - 2010-01-19 01:30:58
**topic**:
id - 128
name - photography
group - photo
created - 2010-01-19 01:30:58
**desc date:**
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| date | date | NO | PRI | NULL | |
| week | varchar(100) | NO | | NULL | |
| month | varchar(100) | NO | | NULL | |
| day | varchar(100) | NO | | NULL | |
| year | varchar(4) | NO | | NULL | |
| id | int(10) unsigned | NO | MUL | NULL | auto_increment |
+-------+------------------+------+-----+---------+----------------+
这是我试过的
select count(distinct p.id),d.month,t.group
from attendee a, feedback cf, topic t ,date d,student es,branch b,provider p
where date(cf.created)=d.date and p.id=b.provider_id and year(cf.created)=2014 and a.class='TopicAttendee' and a.topic_id=t.id and t.group in ('Education','Fit','Graphics','Services') and es.branch_id=b.id and a.student_id=es.id and a.id=cf.attendee_id and cf.status='ACTIVE' and comment is not null and comment != ''
group by d.month,es.branch_id having count(distinct cf.id)=0;
它给我空集(可能是因为查询错误)但我有我的数据库中没有反馈记录的提供者