workbench运行没问题,放到BI里说sql不正确

(SELECT
    mt4_account, mt4_account AS team_leader
FROM
    table_x
WHERE
    mt4_account_type = 5
)

union all

(select mt4_account, referee as team_leader
from
(SELECT
    mt4_account, (LOCATE('5', REVERSE(identity_relation))-1)/2 as n,total_relation,mt4_account_type,referee
FROM
    table_x) as a
where mt4_account_type !=5
and n = 1
)

union all

(select mt4_account, mid(total_relation,(n-1)*9+1,8) as team_leader
from
(SELECT
    mt4_account, (LOCATE('5', REVERSE(identity_relation))-1)/2 as n,total_relation,mt4_account_type
FROM
    table_x) as a
where mt4_account_type !=5
and n >1
)
FineBIwobushilegend 发布于 2018-8-7 10:23
回答问题
悬赏:2 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共6回答
最佳回答
0
离_度发布于2018-8-7 10:23(编辑于 2023-9-6 09:34)
555
最佳回答
0
wobushilegend发布于2018-8-8 10:12(编辑于 2023-9-6 09:34)
555
  • 离_度 离_度 select  mt4_account, mt4_account AS team_leader
    from (
    SELECT
        mt4_account, mt4_account AS team_leader
    FROM
        table_x
    WHERE
        mt4_account_type = 5
    union all
    select mt4_account, referee as team_leader
    from
    (SELECT
        mt4_account, (LOCATE(\'5\', REVERSE(identity_relation))-1)/2 as n,total_relation,mt4_account_type,referee
    FROM
        table_x) as a
    where mt4_account_type !=5
    and n = 1
    union all
    select mt4_account, mid(total_relation,(n-1)*9+1,8) as team_leader
    from
    (SELECT
        mt4_account, (LOCATE(\'5\', REVERSE(identity_relation))-1)/2 as n,total_relation,mt4_account_type
    FROM
        table_x) as a
    where mt4_account_type !=5
    and n >1)aa
    试一下
    回复
    2018-08-08 10:16 
最佳回答
0
wobushilegend发布于2018-8-8 10:27(编辑于 2023-9-6 09:34)
555
  • 离_度 离_度 what??? 我就是把你之前的括号去了 然后外面加了个查询,数据量还不对了?
    回复
    2018-08-08 10:29 
  • wobushilegend wobushilegend(提问者) 评论 离_度 :好了 没问题了 我自己改了一下 还是非常感谢
    回复
    2018-08-08 11:25 
  • 0关注人数
  • 314浏览人数
  • 最后回答于:2018-8-8 11:25
    活动推荐 更多
    热门课程 更多
    返回顶部