数据集为什么会报这个错

image.png

FineReport 帆软用户A45YkexW7S 发布于 2024-1-4 09:55
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
snrtuemcLv8专家互助
发布于2024-1-4 09:57

在order  by 或者group by后加上这个列名

  • 帆软用户A45YkexW7S 帆软用户A45YkexW7S(提问者) 我都加上了
    2024-01-04 10:05 
  • snrtuemc snrtuemc 回复 帆软用户A45YkexW7S(提问者) 似乎是还有其他的having函数上什么的,检查下,这个字段不要的话,在select时候去掉
    2024-01-04 10:09 
  • 帆软用户A45YkexW7S 帆软用户A45YkexW7S(提问者) 回复 snrtuemc select *,\'月\' as tjlb1,count(distinct substring(dm,1,4)) as 数 into #sl from BK (nolock) where substring(cyrq,1,7)=\'${tjrq}\'+\'-\'+\'${tjsj}\' union select *,\'季\' as tjlb1,count(distinct substring(dm,1,4)) as 数 from BK (nolock) where case when substring(cyrq,6,2) in (\'01\',\'02\',\'03\') then substring(cyrq,1,4)+\'一季度\' when substring(cyrq,6,2) in (\'04\',\'05\',\'06\') then substring(cyrq,1,4)+\'二季度\' when substring(cyrq,6,2) in (\'07\',\'08\',\'09\') then substring(cyrq,1,4)+\'三季度\' when substring(cyrq,6,2) in (\'10\',\'11\',\'12\') then substring(cyrq,1,4)+\'四季度\' end =\'${tjrq}\'+\'${tjsj}\' union select *,\'年\' as tjlb1,count(distinct substring(dm,1,4)) as 数 from BK (nolock) where substring(cyrq,1,4) =\'${tjrq}\' order by cyrq select * from #sl (nolock) where tjlb1=\'${tjlb}\'
    2024-01-04 10:24 
  • snrtuemc snrtuemc 回复 帆软用户A45YkexW7S(提问者) 额,你怎么有插入语句,还有临时表,这个在帆软数据集不支持,帆软数据集中只支持查询语句,调用存储过程语句,所以会报错的,建议做成存储过程,在帆软数据集直接调用存储过程
    2024-01-04 10:26 
  • 帆软用户A45YkexW7S 帆软用户A45YkexW7S(提问者) 回复 snrtuemc 但是我其他的模板用临时表没事
    2024-01-04 10:38 
最佳回答
0
runnerLv7资深互助
发布于2024-1-4 09:57

sql粘贴出来一下

  • 帆软用户A45YkexW7S 帆软用户A45YkexW7S(提问者) select *,\'月\' as tjlb1,count(distinct substring(dm,1,4)) as 数 into #sl from BK (nolock) where substring(cyrq,1,7)=\'${tjrq}\'+\'-\'+\'${tjsj}\' union select *,\'季\' as tjlb1,count(distinct substring(dm,1,4)) as 数 from BK (nolock) where case when substring(cyrq,6,2) in (\'01\',\'02\',\'03\') then substring(cyrq,1,4)+\'一季度\' when substring(cyrq,6,2) in (\'04\',\'05\',\'06\') then substring(cyrq,1,4)+\'二季度\' when substring(cyrq,6,2) in (\'07\',\'08\',\'09\') then substring(cyrq,1,4)+\'三季度\' when substring(cyrq,6,2) in (\'10\',\'11\',\'12\') then substring(cyrq,1,4)+\'四季度\' end =\'${tjrq}\'+\'${tjsj}\' union select *,\'年\' as tjlb1,count(distinct substring(dm,1,4)) as 数 from BK (nolock) where substring(cyrq,1,4) =\'${tjrq}\' order by cyrq select * from #sl (nolock) where tjlb1=\'${tjlb}\'
    2024-01-04 10:23 
最佳回答
0
Gun鹏Lv5初级互助
发布于2024-1-4 10:19
在sum那一层的group by 后面加上这个列
  • 帆软用户A45YkexW7S 帆软用户A45YkexW7S(提问者) select *,\'月\' as tjlb1,count(distinct substring(dm,1,4)) as 数 into #sl from BK (nolock) where substring(cyrq,1,7)=\'${tjrq}\'+\'-\'+\'${tjsj}\' union select *,\'季\' as tjlb1,count(distinct substring(dm,1,4)) as 数 from BK (nolock) where case when substring(cyrq,6,2) in (\'01\',\'02\',\'03\') then substring(cyrq,1,4)+\'一季度\' when substring(cyrq,6,2) in (\'04\',\'05\',\'06\') then substring(cyrq,1,4)+\'二季度\' when substring(cyrq,6,2) in (\'07\',\'08\',\'09\') then substring(cyrq,1,4)+\'三季度\' when substring(cyrq,6,2) in (\'10\',\'11\',\'12\') then substring(cyrq,1,4)+\'四季度\' end =\'${tjrq}\'+\'${tjsj}\' union select *,\'年\' as tjlb1,count(distinct substring(dm,1,4)) as 数 from BK (nolock) where substring(cyrq,1,4) =\'${tjrq}\' order by cyrq select * from #sl (nolock) where tjlb1=\'${tjlb}\'
    2024-01-04 10:24 
  • Gun鹏 Gun鹏 回复 帆软用户A45YkexW7S(提问者) 有count 你得有group by分组
    2024-01-04 10:53 
  • 帆软用户A45YkexW7S 帆软用户A45YkexW7S(提问者) 不太明白
    2024-01-04 10:56 
  • Gun鹏 Gun鹏 回复 帆软用户A45YkexW7S(提问者) 比如:select a,b,count(c) from 表 group by a,b
    2024-01-04 11:00 
  • 3关注人数
  • 270浏览人数
  • 最后回答于:2024-1-4 10:19
    请选择关闭问题的原因
    确定 取消
    返回顶部