我如何将以下的SQL语句转换为Java中的QueryDsl呢?

huangapple 未分类评论47阅读模式
英文:

How can i convert the following sql statement to QueryDsl in java?

问题

我尝试从Java代码中使用QueryDSL。但是,在使用带有多个选择子句中的列的内部查询时,我无法访问指定的列。例如r.maxTime

FROM (
      SELECT Train, MAX(Time) as MaxTime
      FROM TrainTable
      GROUP BY Train
) r
INNER JOIN TrainTable t
ON t.Train = r.Train AND t.Time = r.MaxTime```

<details>
<summary>英文:</summary>

I tried to use querydsl from java code. but when using inner query with more the on column in select clause, I cant approach to specified columns. ```r.maxTime``` for example.

```SELECT t.Train, t.Dest, r.MaxTime
FROM (
      SELECT Train, MAX(Time) as MaxTime
      FROM TrainTable
      GROUP BY Train
) r
INNER JOIN TrainTable t
ON t.Train = r.Train AND t.Time = r.MaxTime

</details>


huangapple
  • 本文由 发表于 2020年4月7日 14:45:57
  • 转载请务必保留本文链接:https://java.coder-hub.com/61074250.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定