【问题标题】:spring data -How to sort a list using a calculated columnspring data - 如何使用计算列对列表进行排序
【发布时间】:2023-03-04 05:33:02
【问题描述】:

我不知道如何使用 Pageable 对象按计算列对列表进行排序。

示例:

select  qte, price, (price * qte ) as total 
from table 
order by total

【问题讨论】:

    标签: sql sorting spring-data spring-data-jpa


    【解决方案1】:

    您不能在 order by 子句中引用别名。相反,你会使用:

    SELECT qte, price, (price * qte) as total 
    FROM table 
    ORDER BY  (price * qte)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-24
      • 1970-01-01
      • 2012-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多