0

我有这个sql:

select u.USER from USERS u
left join (
  select sum(OCUPATION) as OCU, USER from OCUPATION
  where CONVERT(DATETIME, DATE, 103) BETWEEN CONVERT(DATETIME, '08/04/2012', 103)
    AND CONVERT(DATETIME, '10/04/2013', 103) group by USER
  ) as ocu on u.USER = ocu.USER
where u.USER_ROLE = 1
and u.USER in (select a.USER from GROUP_USE_CLIE a where ID_CLIENT = 65)
group by u.USER, u.PRIORITY, ocu.OCU
order by PRIORITY, ocu.OCU;

此查询的目的是获取一个列表或用户角色 = 1,可以在客户端 = 65 上工作,然后按优先级排序,最后按 Sum(Ocupation) 排序,这就是我将左连接与子查询一起使用的原因。该查询工作正常,购买我无法将其转换为休眠标准。

有谁能够帮我?

谢谢!

4

0 回答 0