我写的sql:
select iu.subject, iu.commandState,orgtypeInternalid from issuesnew iu,issuelogsnew il
where il.targeorginternalcode like '1.1.1.1.'||'%' and iu.id=il.issueid and iu.id not in(select issueid from historicalIssues
where orgId=4 or orgInternalCode like '1.1.1.1.'||'%')
order by iu.commandState desc,orgtypeInternalid desc
查询结果如下:
显然不正确。正确写法如下:
select iu.subject, iu.commandState,from issuesnew iu,issuelogsnew il
where il.targeorginternalcode like '1.1.1.1.'||'%' and iu.id=il.issueid and iu.id not in(select issueid from historicalIssues
where orgId=4 or orgInternalCode like '1.1.1.1.'||'%')
order by decode(iu.commandState,null,0,iu.commandState) desc,orgtypeInternalid desc