Skip to content

[Bug] DIFF 对于结果集的计算与逻辑不符 #17592

@HuangYuChen1998

Description

@HuangYuChen1998

Search before asking

  • I searched in the issues and found nothing similar.

Version

版本:V2.0.8
系统 Windows 11

Describe the bug and provide the minimal reproduce step

当执行如下SQL时,对于DIFF展示的结果无异议:

select "time" ,
symbol ,
display_name ,
close_hfq ,
ma_3 ,
DIFF(ma_3 ) as "MA_3 斜率",
ATAN(DIFF(ma_3 )) as "MA_3 弧度角"
FROM 
quant.stock_kline_monthly 
where symbol = '600000'
ORDER by "time";
Image

但是我需要查看最近数据的情况,所以需要 Order By time DESC;
这时候我在外面再包一层select

SELECT * FROM (
select "time" ,
symbol ,
display_name ,
close_hfq ,
ma_3 ,
DIFF(ma_3 ) as "MA_3 斜率",
ATAN(DIFF(ma_3 )) as "MA_3 弧度角"
FROM 
quant.stock_kline_monthly 
where symbol = '600000'
ORDER by "time"
)
ORDER by "time" DESC;

这时候得到的结果如下,发现DIFF依然是在最外层Select的基础上处理的,这样不符合SQL中的逻辑:

Image

What did you expect to see?

期待为Diff 只在属于它那一层的结果集上做处理,而不是在最终结果级上(或可能其他原因);
这样可以得到从后向前的diff测点值并,在外层查看到最新值的数据

What did you see instead?

在外层包了一层select 倒序排序后,第一行任然没有diff数据

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions