0

我正在从 1 个表中读取 2 个字段。

开始键和分钟

下图在左侧显示了我当前的输出结果,在右侧显示了我需要的结果。 在此处输入图像描述

这是我的查询

Select
       StartKey,
       Duration as Mins
From   TableA
Where  Flag = 0
Order by StartKey

我知道我可以使用avg(duration),但如果我使用它,我用来编写和显示查询的软件 Obvient 不会让我取列 Mins Avg 本身的平均值。

在此处输入图像描述

在我手动插入 CS 文件中列的平均代码然后我尝试编辑列属性后,我得到了这个错误。
在此处输入图像描述

4

2 回答 2

2

First, let me make sure I understand your problem.

You are using the SQL from your post while building something in Obvient which appears to be a Business Intelligence platform. The problem you are having is that you are unable to perform an average function in Obvient on the column of averages in your SQL query.

If that is correct, you should use your SQL query to create a view in the database which should appear to Obvient as a table and may allow you to perform the averaging function. I can't say for certain that this will solve your issue having never used Obvient, but give that a try and let us know how that works for you.

于 2013-01-24T20:43:57.757 回答
1

好像我错过了一些东西,但是为了得到你想要的结果,这应该有效:

Select
       StartKey,
       AVG(Duration) as Mins
From   TableA
Where  Flag = 0
Group By StartKey
Order by StartKey

还有SQL 小提琴

如果您的目标是从上述查询中获取 AVG(Mins),则可以使用子查询返回:

Select AVG(Mins)
FROM (
   SELECT
       StartKey,
       AVG(Duration) as Mins
    From   TableA
    Group By StartKey
    ) t

这是小提琴

祝你好运。

于 2013-01-24T19:14:17.580 回答