从日志中提取数据,其中同一票证的date_time仅相隔几分钟

时间:2018-09-25 15:31:43

标签: mysql mysql-workbench

我正在尝试获取// Pack of values template <auto...> struct vpack { }; // Concatenating two packs template <class, class> struct vpack_cat_; template <auto... lhs, auto... rhs> struct vpack_cat_<vpack<lhs...>, vpack<rhs...>> { using type = vpack<lhs..., rhs...>; }; template <class Lhs, class Rhs> using vpack_cat = typename vpack_cat_<Lhs, Rhs>::type; // Building a decreasing exp scale... template <int N> struct exp_scale_ { using type = vpack_cat< vpack<N>, typename exp_scale_<N / 2>::type >; }; // ... stopping at 2 template <> struct exp_scale_<2> { using type = vpack<2>; }; template <int N> using exp_scale = typename exp_scale_<N>::type; // Building the tuple's type from the scale template <class ScalePack> struct exp_tuple_; template <auto... Scale> struct exp_tuple_<vpack<Scale...>> { using type = std::tuple<std::array<double, Scale>...>; }; template <class Scale> using exp_tuple = typename exp_tuple_<Scale>::type; // The known get_array() function template <int N> std::array<double,N> get_array() { return {}; } // Initializing the tuple template <auto... Scale> auto get_tuple(vpack<Scale...>) { return exp_tuple<vpack<Scale...>>{ get_array<Scale>()... }; } template <int N> auto get_tuple() { return get_tuple(exp_scale<N>{}); } New_state = Assigned相距仅几分钟的票证的referr_to号码,这意味着有人未正确完成工作并匆忙完成。

我正在尝试为两个事件日志日期时间仅相隔几分钟的事件获取ID号,这意味着某人未正确完成工作。

我尝试将其作为子查询,但显示为:

  

错误代码:1248。每个派生表必须具有自己的别名   找到查询解决方案。

有人可以帮助修复代码或提供新代码吗?下表和内容。

Previous_State = Assigned

auditlog表中的列:

SELECT
b.auditlog.event_date_time,
c.auditlog.event_date_time
FROM

(SELECT
  auditlog.event_date_time
FROM
  servicerequest
  INNER JOIN auditlog ON servicerequest.id = auditlog.refers_to
WHERE
  auditlog.previous_state = 'IN_PROGRESS'
GROUP BY
servicerequest.ticketNumber) as b,


(SELECT
  auditlog.event_date_time
FROM
  servicerequest
  INNER JOIN auditlog ON servicerequest.id = auditlog.refers_to
WHERE
        auditlog.new_state = 'IN_PROGRESS'
    AND
        auditlog.previous_state = 'ASSIGNED')
GROUP BY
servicerequest.ticketNumber) as c
WHERE

c.ticketnumber = b.ticketnumber
LIMIT 5

示例数据的图片: Auditlog Table

0 个答案:

没有答案