我需要将此查询转换为 HQL 语法:
SELECT * FROM my_table
GROUP BY `name`
HAVING MIN(ABS(CAST(202000 AS SIGNED) - CAST(step_id AS SIGNED))) = ABS(CAST(202000 AS
SIGNED) - CAST(step_id AS SIGNED));
我写了这个:
"SELECT DISTINCT t FROM myTable t GROUP BY t.name
HAVING MIN(ABS(CAST(202000 as signed) - CAST(t.step.id as signed))) = ABS(CAST(202000 as signed)- CAST(t.step.id as signed))"
但是我收到编译错误 - 红线位于关键字“signed”下:“无法解析符号“Signed””
我找不到正确将此查询转换为 HQL 的方法。
你能试试这个吗?只是用 int 替换了signed..
选择不同的t 来自 myTable t 按名称分组 HAVING MIN(ABS(CAST(202000 AS 整数) - CAST(t.stepId AS 整数))) = ABS(CAST(202000 AS 整数) - CAST(t.stepId AS 整数))