我想获取下面的CubeJS JSON查询返回的记录计数。
{
"measures": [
"Employee.salaryTotal"
],
"timeDimensions": [
{
"dimension": "Employee.createdat"
}
],
"dimensions": [
"Employee.isactive"
],
"filters": []
}
此JSON查询在CubeJS中的SQL下面生成:
SELECT
`employee`.`isActive` `employee__isactive`,
SUM(salary) `employee__salary_total`
FROM
DEMO.Employee AS `employee`
GROUP BY
1
ORDER BY
2 DESC
LIMIT
10000
SQL的输出是:
+---------------------+------------------------+
| employee__isactive | employee__salary_total |
+---------------------+------------------------+
| Y | 17451 |
| N | 1249 |
+---------------------+------------------------+
但是如果我想通过上面的SQL返回记录数怎么办。
例如:
SELECT COUNT(*) FROM
(SELECT
`employee`.`isActive` `employee__isactive`,
SUM(salary) `employee__salary_total`
FROM
DEMO.Employee AS `employee`
GROUP BY
1
ORDER BY
2 DESC
LIMIT
10000) AS EMPSAL
预期结果应如下:
+------------+
| # COUNT(*) |
+------------+
| 2 |
+------------+
答案 0 :(得分:0)
当前,无法在最终的Cube.js查询之上执行COUNT
操作。如果您要实现分页功能,则可以使用offset
和limit
查询参数通过limit
和行数比较来检查是否存在下一页:{{3} }。