直连式按枚举自定义分组产品编号
自定义分组勾选维度,指标
生成的报错SQL:
select ( case when `ProductID` in (1, 2, 3) then '分组1' when `ProductID` in (4, 5, 6) then '分组2' when `ProductID` in (7, 8, 9, 11, 10) then '分组3' else '其他' end ) as `c0`, sum(`T1`.`Quantity`) as `m0` from `products` as `T3`, `orderdetails` as `T1` where `T1`.`ProductID` = `T3`.`ProductID` and ( case when `ProductID` in (1, 2, 3) then '分组1' when `ProductID` in (4, 5, 6) then '分组2' when `ProductID` in (7, 8, 9, 11, 10) then '分组3' else '其他' end ) in ('其他', '分组1', '分组2', '分组3') group by ( case when `ProductID` in (1, 2, 3) then '分组1' when `ProductID` in (4, 5, 6) then '分组2' when `ProductID` in (7, 8, 9, 11, 10) then '分组3' else '其他' end )
如果直连式生成的SQL改成这样没没问题:
select ( case when `T1`.`ProductID` in (1, 2, 3) then '分组1' when `T1`.`ProductID` in (4, 5, 6) then '分组2' when `T1`.`ProductID` in (7, 8, 9, 11, 10) then '分组3' else '其他' end ) as `c0`, sum(`T1`.`Quantity`) as `m0` from `products` as `T3`, `orderdetails` as `T1` where `T1`.`ProductID` = `T3`.`ProductID` and ( case when `T1`.`ProductID` in (1, 2, 3) then '分组1' when `T1`.`ProductID` in (4, 5, 6) then '分组2' when `T1`.`ProductID` in (7, 8, 9, 11, 10) then '分组3' else '其他' end ) in ('其他', '分组1', '分组2', '分组3') group by `C0`
抽取式建模查询同样的维度,度量勾选没问题 |