如何在oracle中获得总工作时间?

时间:2017-07-03 07:49:41

标签: oracle11g time-tracking

我在oracle 11g中有一个如下表:

@Override
public Response intercept(Chain chain) throws IOException {
    Request original = chain.request();
    Request.Builder requestBuilder = original.newBuilder()
            .header("Content-Type", "application/json")
            .header(Constants.TAG_AUTHORIZATION, "Bearer " + token)
            .method(original.method(), original.body());


    Request request = requestBuilder.build();
    Response response = chain.proceed(request);
    if (response.code() == 200) {
        String json = response.body().string();
        try {
            JSONObject obj = new JSONObject(json);
            int code = obj.getInt(Constants.TAG_CODE);
            if (code == Constants.REQUEST_CODE_TOKEN_EXPIRED) {
                Response r = makeTokenRefreshCall(request, chain);
                return r;
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    return response;
}

我想计算用户的总工作时间。

你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

select
  sum((x.activity_time - to_date('01.01.2017', 'DD.MM.YYYY') * decode(x.activity_type,'LOGIN',-1,1))
from
  your_table x
;

虽然这仅在列表以Login开头并以Logout结束时才有效。