这样写有什么问题?
SQL code
select pr.logid,pr.siteid,pr.recodtime,po.dynamos,po.elecqty from productlog pr left outer join powerunits po on pr.logid=po.logid and pr.siteid=po.siteid
where pr.recodtime between to_char(Trunc(sysdate,'month'),'yyyy-mm-dd') and to_char(sysdate,'yyyy-mm-dd');
------解决方案--------------------为何时间要to_char? pr.recordtime是日期类型的吧
------解决方案--------------------怀疑会有什么问题呢?
------解决方案--------------------select pr.logid, pr.siteid, pr.recodtime, po.dynamos, po.elecqty
from productlog pr
left outer join powerunits po on pr.logid = po.logid
and pr.siteid = po.siteid
where pr.recodtime between to_char(Trunc(sysdate, 'month'), 'yyyy-mm-dd') and
to_char(sysdate, 'yyyy-mm-dd');
--如果recodtime字段为日期型 文字与格式字符串不酝酿匹配
------解决方案--------------------pr.recodtime 这个字段什么类型?
日期可以直接使用 between and