请问这是为啥出错啊

image.png

代码如下

select '销量', a.xy,a.ax,a.zx from

(select xy_sale as xy, ax_sale as ax, zx_sale as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

union 

select '收入', a.xy,a.ax,a.zx from

(select xy_income as xy, ax_income as ax, zx_income as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

union 

select '毛利', a.xy,a.ax,a.zx from

(select xy_gross as xy, ax_gross as ax, zx_gross as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

FineReport 用户x076327 发布于 2022-5-16 11:09
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
2
Z4u3z1Lv6专家互助
发布于2022-5-16 11:13(编辑于 2022-5-16 11:13)

另外 别名不要都是a  太容易混淆了

select '销量' as '销量', a.xy,a.ax,a.zx from

(select xy_sale as xy, ax_sale as ax, zx_sale as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

union 

select '收入', a.xy,a.ax,a.zx from

(select xy_income as xy, ax_income as ax, zx_income as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

union 

select '毛利', a.xy,a.ax,a.zx from

(select xy_gross as xy, ax_gross as ax, zx_gross as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

  • Z4u3z1 Z4u3z1 回复 用户x076327(提问者) 是全部SQL么??? 不应该啊
    2022-05-16 11:23 
最佳回答
0
lgyxtaLv5初级互助
发布于2022-5-16 12:10

类似这种单条会报错嘛

select xy_sale as xy, ax_sale as ax, zx_sale as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

最佳回答
0
霜凡Lv5中级互助
发布于2022-5-16 13:29

select '销量' as 类型, xy, ax, zx from

(select xy_sale as xy, ax_sale as ax, zx_sale as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as a

union 

select '收入' as 类型, xy, ax, zx from

(select xy_income as xy, ax_income as ax, zx_income as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as b

union 

select '毛利' as 类型, xy, ax, zx from

(select xy_gross as xy, ax_gross as ax, zx_gross as zx from app_db.yp_xs_d_his_hy where calday=translate(substr(date_sub(CURRENT_DATE(),1) , 1 ,10 ),'-','')

) as c

  • 3关注人数
  • 334浏览人数
  • 最后回答于:2022-5-16 13:29
    请选择关闭问题的原因
    确定 取消
    返回顶部