orderby语句应该怎么拼接到这个sql语句里啊,求助

1d0ce4a2-3e34-455f-96bf-0e72ef3c8c80.png

   ${IF(送审结束否="", "SELECTmshipno AS shipno,dwg1,dwg2,dwg3,"+船号_BASESHIP+".dwgno,chuturi,"+船号_cd+".altno,ship1,songsri,fangqri,rusri,wancri,xwfqri,commt,reply,commtfile,replyfile,closed,cr,bzFROM"+船号_BASESHIP+"LEFT OUTER JOIN"+船号_cd+"ON"+船号_cd+".dwgno="+船号_BASESHIP+".dwgnoWHERE(chuand='Y' OR chuand='R')"+ IF(LEN(图号)=0,"","AND "+船号+".dwgno LIKE '%"+图号+"%'") + IF(LEN(返却状态)=0,"","AND (fangqri IS NULL AND xwfqri IS NULL) OR (fangqri IS NULL AND DATEDIFF(day,xwfqri,getdate())>0)") + IF(LEN(开始日期)=0,"","AND "+船号_cd+".songsri>='"+开始日期+"'") + IF(LEN(结束日期)=0,"","AND "+船号_cd+".songsri<='"+结束日期+"'") + IF(LEN(科室)=0,"","AND "+船号_BASESHIP+".bm IN ('"+SUBSTITUTE(科室,",","','")+"')") +\"ORDER BY mshipno,\"船号_cd\".altno,\"船号_cd\".ship1\",  "SELECTshipno,dwg1,dwg2,dwg3,"+船号_BASESHIP+".dwgno,chuturi,"+船号+"_cd.altno,ship1,songsri,fangqri,rusri,wancri,xwfqri,commt,reply,commtfile,replyfile,closed,cr,bzFROM"+船号+"_cd,"+船号_BASESHIP+"WHERE"+船号+"_cd.closed LIKE '%"+送审结束否+"%'AND "+船号+"_cd.dwgno="+船号_BASESHIP+".dwgno"+ IF(LEN(图号)=0,"","AND "+船号+"_cd.dwgno LIKE '%"+图号+"%'") + IF(LEN(返却状态)=0,"","AND (fangqri IS NULL AND xwfqri IS NULL) OR (fangqri IS NULL AND DATEDIFF(day,xwfqri,getdate()) >0)") + IF(LEN(开始日期)=0,"","AND "+船号_cd+".songsri>='"+开始日期+"'") + IF(LEN(结束日期)=0,"","AND "+船号_cd+".songsri<='"+结束日期+"'") + IF(LEN(科室)=0,"","AND "+船号_BASESHIP+".bm IN ('"+SUBSTITUTE(科室,",","','")+"') "))} image.png

3342bbeeba-eeb6-4d28-95d9-4e398f822668.png

FineReport HmjijsbZ 发布于 2024-4-17 12:26 (编辑于 2024-4-17 13:41)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
snrtuemcLv8专家互助
发布于2024-4-17 12:31(编辑于 2024-4-17 13:44)

sql语句能发出来吗,在提问发下原来语句

===========

XXXX+"') order by mshipno,"+船号_cd+".altno,"+船号_cd+".ship1"),"select 

shipno,dwg1,dwg2,dwg3,XXXXXXX

=========

 ${IF(送审结束否="", "SELECTmshipno AS shipno,dwg1,dwg2,dwg3,"+船号_BASESHIP+".dwgno,chuturi,"+船号_cd+".altno,ship1,songsri,fangqri,rusri,wancri,xwfqri,commt,reply,commtfile,replyfile,closed,cr,bzFROM"+船号_BASESHIP+"LEFT OUTER JOIN"+船号_cd+"ON"+船号_cd+".dwgno="+船号_BASESHIP+".dwgnoWHERE(chuand='Y' OR chuand='R')"+ IF(LEN(图号)=0,"","AND "+船号+".dwgno LIKE '%"+图号+"%'") + IF(LEN(返却状态)=0,"","AND (fangqri IS NULL AND xwfqri IS NULL) OR (fangqri IS NULL AND DATEDIFF(day,xwfqri,getdate())>0)") + IF(LEN(开始日期)=0,"","AND "+船号_cd+".songsri>='"+开始日期+"'") + IF(LEN(结束日期)=0,"","AND "+船号_cd+".songsri<='"+结束日期+"'") + IF(LEN(科室)=0,"","AND "+船号_BASESHIP+".bm IN ('"+SUBSTITUTE(科室,",","','")+"') order by mshipno,"+船号_cd+".altno,"+船号_cd+".ship1"),  "SELECTshipno,dwg1,dwg2,dwg3,"+船号_BASESHIP+".dwgno,chuturi,"+船号+"_cd.altno,ship1,songsri,fangqri,rusri,wancri,xwfqri,commt,reply,commtfile,replyfile,closed,cr,bzFROM"+船号+"_cd,"+船号_BASESHIP+"WHERE"+船号+"_cd.closed LIKE '%"+送审结束否+"%'AND "+船号+"_cd.dwgno="+船号_BASESHIP+".dwgno"+ IF(LEN(图号)=0,"","AND "+船号+"_cd.dwgno LIKE '%"+图号+"%'") + IF(LEN(返却状态)=0,"","AND (fangqri IS NULL AND xwfqri IS NULL) OR (fangqri IS NULL AND DATEDIFF(day,xwfqri,getdate()) >0)") + IF(LEN(开始日期)=0,"","AND "+船号_cd+".songsri>='"+开始日期+"'") + IF(LEN(结束日期)=0,"","AND "+船号_cd+".songsri<='"+结束日期+"'") + IF(LEN(科室)=0,"","AND "+船号_BASESHIP+".bm IN ('"+SUBSTITUTE(科室,",","','")+"') "))} image.png

  • HmjijsbZ HmjijsbZ(提问者) 大佬,我贴上了,麻烦您看一下呢
    2024-04-17 13:32 
  • snrtuemc snrtuemc 回复 HmjijsbZ(提问者) 你拷贝出来的和你截图不一致,好多+没有了,你看啊看那我的修改答案,中间加了写法,我截图框一下
    2024-04-17 13:38 
  • HmjijsbZ HmjijsbZ(提问者) 回复 snrtuemc 大佬,辛苦您再看一下,我把正确的sql语句放上了
    2024-04-17 13:42 
  • snrtuemc snrtuemc 回复 HmjijsbZ(提问者) 看修改答案
    2024-04-17 13:43 
  • HmjijsbZ HmjijsbZ(提问者) 回复 snrtuemc 谢谢大佬,解决了
    2024-04-17 16:40 
  • 2关注人数
  • 217浏览人数
  • 最后回答于:2024-4-17 13:44
    请选择关闭问题的原因
    确定 取消
    返回顶部