一直报错没找到原因

image.png

select 

 agent_id '总仓ID',s.title '总仓名称',

 material_id '物料ID',m.title '物料名称',m.specification '物料规格',

 sum(case when agent_order_id>0 then 1 else 0 end) as '进货数量',

 sum(case when agent_order_id>0 and order_id>0 then 1 else 0 end) as '销售数量',

 r.pid,

 rg.aname

 from shop_material_detail md 

 join agent s on md.agent_id=s.id 

 join material m on md.material_id=m.id 

 join region r on r.id=s.region_id

 join region rg on r.pid=rg.id

 /*where md.created BETWEEN UNIX_TIMESTAMP('2022-10-30') and UNIX_TIMESTAMP('2022-12-31')*/

 where md.created between UNIX_TIMESTAMP('${tstart1}') and UNIX_TIMESTAMP('${tend1}')+86400 

 and agent_order_id>0

 and  (rg.city in (select city from fr_access_app_v2 where username = '${pa}'))

 GROUP BY md.agent_id,material_id,r.pid,

 rg.aname

FineReport 百煮味香 发布于 2023-4-11 10:38 (编辑于 2023-4-11 10:39)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
CD20160914Lv8专家互助
发布于2023-4-11 10:40(编辑于 2023-4-11 10:46)

select 

 agent_id '总仓ID',s.title '总仓名称',

 material_id '物料ID',m.title '物料名称',m.specification '物料规格',

 sum(case when agent_order_id>0 then 1 else 0 end) as '进货数量',

 sum(case when agent_order_id>0 and order_id>0 then 1 else 0 end) as '销售数量',

 r.pid,

 rg.aname

 from shop_material_detail md 

 join agent s on md.agent_id=s.id 

 join material m on md.material_id=m.id 

 join region r on r.id=s.region_id

 join region rg on r.pid=rg.id

 /*where md.created BETWEEN UNIX_TIMESTAMP('2022-10-30') and UNIX_TIMESTAMP('2022-12-31')*/

 where md.created between UNIX_TIMESTAMP('${tstart1}') and UNIX_TIMESTAMP('${tend1}')+86400 

 and agent_order_id>0

 and  (rg.city in (select city from fr_access_app_v2 where username = '${pa}'))

 GROUP BY  agent_id,s.title, material_id ,m.title ,m.specification ,r.pid, rg.aname

最佳回答
0
runnerLv7资深互助
发布于2023-4-11 10:40(编辑于 2023-4-11 10:45)

select 

 agent_id '总仓ID',s.title '总仓名称',

 material_id '物料ID',m.title '物料名称',m.specification '物料规格',

 sum(case when agent_order_id>0 then 1 else 0 end) as '进货数量',

 sum(case when agent_order_id>0 and order_id>0 then 1 else 0 end) as '销售数量',

 r.pid,

 rg.aname

 from shop_material_detail md 

 join agent s on md.agent_id=s.id 

 join material m on md.material_id=m.id 

 join region r on r.id=s.region_id

 join region rg on r.pid=rg.id

 /*where md.created BETWEEN UNIX_TIMESTAMP('2022-10-30') and UNIX_TIMESTAMP('2022-12-31')*/

 where md.created between UNIX_TIMESTAMP('${tstart1}') and UNIX_TIMESTAMP('${tend1}')+86400 

 and agent_order_id>0

 and rg.city in (select city from fr_access_app_v2 where username = '${pa}')

 GROUP BY md.agent_id,material_id,r.pid,rg.aname,,s.title,m.title,m.specification

----------

image.png

感觉还是这段的问题,你之前有个括号

最佳回答
0
qiqits1984Lv6中级互助
发布于2023-4-11 10:43

image.png

  • 4关注人数
  • 289浏览人数
  • 最后回答于:2023-4-11 10:46
    请选择关闭问题的原因
    确定 取消
    返回顶部