如何在teradata中转换按级别连接

发布于 2024-12-17 05:06:02 字数 291 浏览 0 评论 0原文

我试图将oracle的connect by level功能转换为teradata。我在网上看到了很多例子,但这个特定的例子不同,

 (SELECT 
     CASE LEVEL 
        WHEN 1 THEN 'MB'
        WHEN 2 THEN 'SB'
        ELSE 'TOTAL'
     END AS DRUG_SOURCE
 FROM
    DUAL 
 CONNECT BY LEVEL <= 3) RW  

如果你们有任何想法,请告诉我。

I was trying to convert the connect by level function of oracle to teradata. I have seen many examples over the net but this particular one is different,

 (SELECT 
     CASE LEVEL 
        WHEN 1 THEN 'MB'
        WHEN 2 THEN 'SB'
        ELSE 'TOTAL'
     END AS DRUG_SOURCE
 FROM
    DUAL 
 CONNECT BY LEVEL <= 3) RW  

Please let me know if you guys have any idea.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桃扇骨 2024-12-24 05:06:02

嘿,我找到了解决方案。抱歉,我无法清楚地解释我的问题。

下面的代码将完全按照我在 Teradata 中想要的方式工作

select 'MB' as DRUG_SOURCE from dual  
union  
select 'SB' as DRUG_SOURCE from dual  
Union  
select 'TOTAL' as DRUG_SOURCE from dual  

Hey I found the solution for this. Sorry I couldn't explain my question clearly.

The below code would work exactly the way i wanted in teradata

select 'MB' as DRUG_SOURCE from dual  
union  
select 'SB' as DRUG_SOURCE from dual  
Union  
select 'TOTAL' as DRUG_SOURCE from dual  
度的依靠╰つ 2024-12-24 05:06:02

你可以试试这个代码:

select DRUG_SOURCE from (select 'MB' as DRUG_SOURCE,1 as id) a
union all
select DRUG_SOURCE from (select 'SB' as DRUG_SOURCE,2 as id) b
union all
select DRUG_SOURCE from (select 'TOTAL' as DRUG_SOURCE,3 as id) c

You can try this code:

select DRUG_SOURCE from (select 'MB' as DRUG_SOURCE,1 as id) a
union all
select DRUG_SOURCE from (select 'SB' as DRUG_SOURCE,2 as id) b
union all
select DRUG_SOURCE from (select 'TOTAL' as DRUG_SOURCE,3 as id) c
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文