我正在尝试编辑Crystal Reports SQL Expression,其中原始设计器使用以下SQL Expression从驱动器中提取注释:
(select max(Text) from rpt_NotesDetail
where DriveID="DriveMaster"."DriveID" and
Reason in (select codeid
from rpt_QuickCodes
where DescShort like N'Publicity'))
我们不希望它提取最大值(文本),我们正在寻找它根据创建的字段获取NotesDetail表中的最新(或最新)注释。
我尝试了两种方法来解决这个问题,而且我在两个方面都遇到了错误:
(select (Text) from rpt_NotesDetail
where DriveID="DriveMaster"."DriveID"
and createdate = (select max(createdate)
from rpt_notesdetail
where DriveID="DriveMaster"."DriveID")
and Reason in (select codeid
from rpt_QuickCodes
where DescShort like N'Publicity'))
(select (Text)
from rpt_NotesDetail
where DriveID="DriveMaster"."DriveID"
and createdate = (select top 1 createdate
from rpt_notesdetail
where DriveID="DriveMaster"."DriveID"
order by "drivemaster"."fromdatetime" desc)
and Reason in (select codeid
from rpt_QuickCodes
where DescShort like N'Publicity'))
这两个表达式都给了我这个错误: 子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =时,或子查询用作表达式时,不允许这样做。
不确定这个错误的原因是什么,有什么建议吗?