*对不起,我犯了一些错误和粗暴的举止。
现在我尝试使用AlaSql制作销售汇总报告,继承我的代码:
table {border:1px solid black}
<script src="https://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script>
<p>ROLLUPTEST()</p><div id="res1"></div>
{ Area: "Area 1", Shop: "Shop 1" , Val: 5 },
{ Area: "Area 1", Shop: "Shop 2" , Val: 20 },
{ Area: "Area 1", Shop: "SUBTOTAL", Val: 25 },
{ Area: "Area 2", Shop: "Shop 1" , Val: 25 },
{ Area: "Area 2", Shop: "Shop 2" , Val: 40 },
{ Area: "Area 2", Shop: "SUBTOTAL", Val: 65 },
{ Area: "ALL" , Shop: "TOTAL" , Val: 90 },
我希望在表格中显示价值摘要。
var x = Request.Files;
var y = Request.Form["model"];
但是当运行它时,调试器会显示“脚本错误”。 浏览器中没有表格显示。
我猜AlaSql不支持GROUPING功能。 如果有人知道这件事,请告诉我。
答案 0 :(得分:0)
不,AlaSQL仅在另一个上下文中知道GROUPING
keyword,即在GROUPING SETS
中:
GROUP BY GROUPING SETS(Area, Shop)
如果您的Area
和Shop
字段为非空,则可以按如下方式处理:
SELECT CASE WHEN Area IS NULL THEN "ALL" ELSE Area END AS Area,
CASE WHEN Shop IS NULL THEN
CASE WHEN Area IS NULL THEN "TOTAL" ELSE "SUBTOTAL" END
ELSE Shop
END as Shop,
SUM(Val) AS Val
INTO HTML("#res1", {headers:true})
FROM ?
GROUP BY ROLLUP(Area,Shop)