运行以下查询以使用createdOn列获取包含最新数据的最新消息 我得到以下错误
select count(m) from MessageWorkFlowStatus mwfs1 where mwfs1.createdOn =(select max(createdOn) from MessageWorkFlowStatus mwfs2 where mwfs1.status= 'NEW' or mwfs1.status='IN PROGRESS')
封装的表达式不是有效的表达式
如果我能以这种方式运行查询,请告诉我
答案 0 :(得分:1)
首先,count(m)
不正确。它应该是count(*)
或count(mwfs1)
。其次,在内部查询中,您正在使用外部查询表(mswfs1)中的状态列,这在逻辑上是错误的。它应该是mwfs2.status = 'NEW' or mwfs2.status = 'IN PROGRESS'
。
我认为你的查询应该是:
select count(mwfs1)
from MessageWorkFlowStatus mwfs1
where mwfs1.createdOn = (
select max(createdOn)
from MessageWorkFlowStatus mwfs2
where mwfs2.status= 'NEW' or mwfs2.status='IN PROGRESS')