select d.department_name,
mt.type_name,
'2017-02-07' as startdate,
'2017-02-07' as enddate,
m.msgcount * ms.proportion / 100 record_count
from (select ml.message_type, count(1) msgcount
from message_send_log ml
group by ml.message_type) m,
mesophase_statistics ms,
base_department d,
base_message_type mt
where m.message_type = ms.message_type
and ms.dept_id = d.department_id
and ms.message_type = mt.type_id
and to_date(ml.send_time,'yyyy-MM-dd') >= to_date('2017-02-07', 'yy-mm-dd')
select ml.message_type, count(1) msgcount
from message_send_log ml
你的ml 职业这两列,没send_time,所以就无效了
第一:字段名是否正确。
第二:是否有中文字符
第三:再找找,再看看
我检查过了,绝对不是列名不一样,也不是啥关键字。。。就是不知道为啥没用
没有哪位大神可以看出问提在哪么?
sql写的不对,
select d.department_name,
mt.type_name,
'2017-02-07' as startdate,
'2017-02-07' as enddate,
m.msgcount * ms.proportion / 100 record_count
from (**select ml.message_type, count(1) msgcount
from message_send_log ml
group by ml.message_type**) m,
mesophase_statistics ms,
base_department d,
base_message_type mt
where m.message_type = ms.message_type
and ms.dept_id = d.department_id
and ms.message_type = mt.type_id
and to_date(ml.send_time,'yyyy-MM-dd') >= to_date('2017-02-07', 'yy-mm-dd')
这个sql里面的表关联有m, ms, mt,d 已经没有ml了,ml那个表是作为子查询了,如果需要的话应该把
select ml.message_type, count(1) msgcount
from message_send_log ml group by ml.message_type
这个加上 send_time这一列,在where条件中用m.send_time
select ml.message_type, count(1) msgcount
from message_send_log ml
group by ml.message_type
这一段的内层查询没有查询出send_time这个字段的数据。
select ml.message_type,ml.send_time, count(1) msgcount
from message_send_log ml
group by ml.message_type
下边调用的时候可以用ml.send_time,也可以是m.send_time
楼主,我是这么觉得的,如果你觉得你的sql写不到你心目中的情况,不如用程序进一步处理
select d.department_name,
mt.type_name,
'2017-02-07' as startdate,
'2017-02-07' as enddate,
m.msgcount * ms.proportion / 100 record_count
from (select ml.message_type,ml.send_time, count(1)over( partition by msgcount) as msgcount
from message_send_log ml) m,
mesophase_statistics ms,
base_department d,
base_message_type mt
where m.message_type = ms.message_type
and ms.dept_id = d.department_id
and ms.message_type = mt.type_id
and to_date(m.send_time,'yyyy-MM-dd') >= to_date('2017-02-07', 'yy-mm-dd')