1、in
假设List listParam;listParam里面已经有数据了,则HQL查询条件可以为:
String hql=“SELECT * FROM T WHERE T.ID IN (:list)”;
Query query = getSession().createQuery(hql);
query.setParameterList(“list”, listParam);
2、date to char
SELECT to_char(DATETIME,‘yyyy-mm-dd hh24:mi:ss’) FROM “T”
3、to_date()
select to_date(‘2005-01-01 13:14:20’,‘yyyy-mm-dd hh24:mi:ss’) from dual
4、保留两位小数
函数 ROUND(122.3467 , 2 ) 结果为122.35
5、case when
case when a=‘1’ then ‘1’
when a=‘2’ then ‘2’
else ‘3’ end as a
6、求绝对值
select abs(-5) from dual;
oracle hql基本用法
于 2021-08-09 16:10:27 首次发布
本文介绍了SQL查询中的几个关键技巧,包括使用IN操作符筛选列表中的ID,利用to_char和to_date函数进行日期格式转换,运用ROUND函数进行数值四舍五入,以及如何使用CASE WHEN构造条件判断表达式。这些技巧在SQL查询中非常实用,能帮助提升数据处理的效率和准确性。
摘要由CSDN通过智能技术生成