页面预览出错,数据库正常 ,去掉ORDER by就正常

select rc.BOOKKEEPING_DATE,YEAR(CONVERT(CHAR, rc.BOOKKEEPING_DATE, 111)) AS YEAR  ,convert(varchar(7),rc.BOOKKEEPING_DATE,120) as n,month(rc.BOOKKEEPING_DATE) as 月 ,cy.COMPANY_NAME,c.CUSTOMER_FULL_NAME,(rc.TAX_FC+rc.AMT_UNTAX_FC) as z,rc.ACCOUNT_YEAR from RECEIVABLE_DOC as rc inner join COMPANY as cy on rc.Owner_Org_ROid = cy.COMPANY_ID

inner join CUSTOMER as c on c.CUSTOMER_BUSINESS_ID=rc.SETTLEMENT_CUSTOMER_ID

where  (1=1 AND rc.ApproveStatus='Y')  ORDER by convert(varchar(7),rc.BOOKKEEPING_DATE,120) asc

image.png

FineReport 用户B3Z4M8196127 发布于 2022-5-7 17:00 (编辑于 2022-5-7 17:01)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
用户B3Z4M8196127Lv2见习互助
发布于2022-5-9 11:37

放到条件最后,就可以了

最佳回答
0
15922204585Lv6高级互助
发布于2022-5-7 17:02

select rc.BOOKKEEPING_DATE,YEAR(CONVERT(CHAR, rc.BOOKKEEPING_DATE, 111)) AS YEAR  ,convert(varchar(7),rc.BOOKKEEPING_DATE,120) as n,month(rc.BOOKKEEPING_DATE) as 月 ,cy.COMPANY_NAME,c.CUSTOMER_FULL_NAME,(rc.TAX_FC+rc.AMT_UNTAX_FC) as z,rc.ACCOUNT_YEAR from RECEIVABLE_DOC as rc inner join COMPANY as cy on rc.Owner_Org_ROid = cy.COMPANY_ID

inner join CUSTOMER as c on c.CUSTOMER_BUSINESS_ID=rc.SETTLEMENT_CUSTOMER_ID

where  1=1 AND rc.ApproveStatus='Y'

ORDER by convert(varchar(7),rc.BOOKKEEPING_DATE,120) asc

去掉括号

最佳回答
0
CD20160914Lv8专家互助
发布于2022-5-7 17:35

select t.* from (

select 

rc.BOOKKEEPING_DATE,

YEAR(CONVERT(CHAR, rc.BOOKKEEPING_DATE, 111)) AS YEAR  ,

convert(varchar(7),rc.BOOKKEEPING_DATE,120) as n,

month(rc.BOOKKEEPING_DATE) as 月 ,

cy.COMPANY_NAME,

c.CUSTOMER_FULL_NAME,(rc.TAX_FC+rc.AMT_UNTAX_FC) as z,

rc.ACCOUNT_YEAR 

from RECEIVABLE_DOC as rc 

inner join COMPANY as cy on rc.Owner_Org_ROid = cy.COMPANY_ID

inner join CUSTOMER as c on c.CUSTOMER_BUSINESS_ID=rc.SETTLEMENT_CUSTOMER_ID

where  

1=1 

AND rc.ApproveStatus='Y' 

) t

order by t.n

再多套一层看。这样是否报错?

  • 用户B3Z4M8196127 用户B3Z4M8196127(提问者) 不加筛选条件,不会出错
    2022-05-07 17:43 
  • CD20160914 CD20160914 回复 用户B3Z4M8196127(提问者) 你哪里加了什么筛选条件??
    2022-05-07 17:46 
  • 用户B3Z4M8196127 用户B3Z4M8196127(提问者) 回复 CD20160914 ${if(len(a)=0,\"\",\"and rc.ACCOUNT_YEAR= \'\"+a+\"\'\")} ${if(len(company)=0,\"\",\"and cy.COMPANY_NAME=\'\"+company+\"\'\")} ${if(len(customer)=0,\"\",\"and c.CUSTOMER_FULL_NAME = \'\"+customer+\"\'\")}
    2022-05-07 18:46 
  • CD20160914 CD20160914 回复 用户B3Z4M8196127(提问者) 你把所有完整的写出来吧。。编辑在你最上面。
    2022-05-07 19:54 
  • 2关注人数
  • 397浏览人数
  • 最后回答于:2022-5-9 11:37
    请选择关闭问题的原因
    确定 取消
    返回顶部