日期:2014-05-16  浏览次数:20846 次

高分请教高手,在oracle中 sql转hql
Java code

select tt.date1, count(tt.id)
  from (select t.user_id id,
               to_char(t.login_time, 'yyyy-mm') date1
          from v2_user_login_log t
         group by to_char(t.login_time, 'yyyy-mm'), t.user_id
        having count(*) > 5) tt
 group by date1
 order by date1 desc




------解决方案--------------------
你这句话没用到特殊语法,应该没区别的。直接写就行了,

我自己是这么用的,不知道理解错了没。

<!-- 查询统计数据:属性值 -->
<select id="getStatisticsDataByOrgIndprocode2" parameterType="java.lang.String" resultMap="dataViewMap">
select * from 
(
${selectClause}
where indCode = #{indCode} and RangeMinDate &gt;= to_date(#{beginDate},'yyyymmdd') and RangeMinDate &lt;= to_date(#{endDate} ,'yyyymmdd')
<if test="indProCode != null"> and IndProCode=#{indProCode}</if>
<if test="province != null"> and Province =#{province}</if>
<if test="cityp != null"> and Cityp =#{cityp}</if>
<if test="region != null"> and Region =#{region}</if>
<if test="orgCode != null"> and OrgCode =#{orgCode}</if>
<if test="deptCode != null"> and DeptCode =#{deptCode}</if>
${groupByClause}
) ${pivotClause}
</select>
------解决方案--------------------
是HIVE-QL吗?
SQL code
select tt.date1, count(tt.id)
  from (select t.user_id id,
               SUBSTR(t.login_time,1,7) date1
          from v2_user_login_log t
         group by SUBSTR(t.login_time,1,7), t.user_id
        having count(*) > 5) tt
 group by date1
 order by date1 desc