作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有什么方法可以让我在 SELECT 子句中使用一个带有子查询的选择散列,以便在 SqlUtil::AbstractTable 上使用方法(如 getRowIterator())。
我在 select_option_superquery 中发现了类似的东西但是在那里使用的子查询可以在 FROM 子句中找到:
SELECT serviceid, service_methodid FROM (SELECT serviceid,service_methodid..)...
SELECT t1.id, t1.order_id,
(SELECT COUNT(order_id) FROM tbl1 t2 WHERE t1.order_id = t2.order_id) as count,
t1.other_cols,
t3.other_cols
FROM tbl1 t1 left join tbl3 s on t1.id = t3.id
order_id
tbl1
id order_id other_cols
1 ord1 ...
2 ord2 ...
3 ord1 ...
id order_id count other_cols
1 ord1 2 ...
2 ord2 1 ...
3 ord1 2 ...
最佳答案
您不能完全按照您的意愿执行此操作(使用子查询作为选择列),但您可以使用 superquery 执行此操作。您提到的选项,并通过使用 SQL 窗口函数与 SqlUtil 和 cop_over() function
代码可能如下所示:
list cols = (
"id",
"order_id",
cop_as(cop_over(cop_count("order_id"), "order_id"), "count"),
# ... other columns to select here - this is in the inner query
);
hash sh = (
"columns": cols,
"join": join_inner(t2, "t2", ("order_id": "order_id")) +
join_inner(t3, "t3", ("id": "id")),
"superquery": (
"columns": (
cop_distinct("id"), "order_id", "count"
# note put columns needed here without table prefixes, this is for the outer query
),
),
);
t2
中必须至少有一行。 .
t2
是可选的,使用
join_left()
而不是
join_inner()
.
string sql;
list l = t1.selectRows(sh, \sql);
log(LL_INFO, "sql: %s", sql);
log(LL_INFO, "SQL results: %N", l);
关于sql - Qorus 嵌套选择哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41503112/
有什么方法可以让我在 SELECT 子句中使用一个带有子查询的选择散列,以便在 SqlUtil::AbstractTable 上使用方法(如 getRowIterator())。 我在 select_
有没有办法在 Qorus 集成引擎中指定用于 REST 连接的协议(protocol)(HTTP 或 HTTPS)? 我试图检查定义其余 URL 的连接文件,但似乎找不到指定协议(protocol)的
我有一个 service它指的是一些外部文件系统资源,如 html、css 等,……由于向它们传递了不正确的路径,因此无法在 Windows 中加载。 有什么方法可以在 Qorus 中检索操作系统的文
我是一名优秀的程序员,十分优秀!