这是我加入的数据的基本布局。
+---------+--------------------+----------+------------------------+
| IssueId | Path | Data | Actual Create Date |
+---------+--------------------+----------+------------------------+
| 1234 | /status | Open | 04/20/2018 16:20:22 |
| 1234 | /next_step_action | Comment | 04/20/2018 16:20:22 |
| 1234 | /next_step/action | Step 2 | 04/20/2019 17:20:20 |
| 1234 | /next_step/action | Comment | 04/20/2019 18:20:20 |
| 1234 | /next_step/action | Step 3 | 04/20/2019 20:20:20 |
| 1234 | /next_step/action | Comment | 04/21/2019 08:20:20 |
| 5678 | /status | Open | 04/22/2018 22:20:22 |
| 5678 | /next_step_action | Comment | 04/22/2018 22:20:22 |
| 5678 | /next_step/action | Step 2 | 04/20/2019 23:20:20 |
| 5678 | /next_step/action | Comment | 04/20/2019 23:25:20 |
| 5678 | /next_step/action | Step 3 | 04/20/2019 23:27:20 |
| 5678 | /next_step/action | Comment | 04/21/2019 23:45:20 |
+---------+--------------------+----------+------------------------+
编辑:
我尝试了下面的答案,它似乎是一个永无止境的查询。所以我基于它编写了以下内容,它似乎正常工作:
SELECT
`IssueId`,
`Path`,
`Data`,
`Actual Create Date`
FROM
SIM_FE_Audit_Data a
WHERE
`Data` IN ( 'Open', 'Comment', 'Pending Others', 'Work in Progress', 'Resolved' )
AND NOT
`IssueId` IN (
SELECT
`IssueId`
FROM
SIM_FE_Audit_Data b
WHERE
a.`Actual Create Date` = b.`Actual Create Date`
AND
a.`Data` = 'Comment'
AND
b.`Data` = 'Open'
)
ORDER BY `IssueId`, `Actual Create Date`
然后我在常见的IssueId上添加了一个内连接:
SELECT
`a`.`AssignedFolderLabel` AS `Folder`,
`a`.`IssueId` AS `Id`,
`a`.`IssueUrl` AS `IssueUrl`,
`b`.`ShortId` AS `ShortId`,
`a`.`Severity` AS `Severity`,
`a`.`Title` AS `Issue_Description`,
`a`.`Request_Type` AS `Request_Type`,
`a`.`Site` AS `Site`,
`b`.`Path` AS `Path`,
`b`.`Data` AS `Data`,
`b`.`Actual Create Date` AS `Actual Create Date`
FROM
SIM_FE a
INNER JOIN (
SELECT
`b`.`IssueId` AS `Id`,
`b`.`ShortId`,
`b`.`Path` AS `Path`,
`b`.`Data` AS `Data`,
`b`.`Actual Create Date` AS `Actual Create Date`
FROM
`SIM_FE_Audit_Data` `b`
WHERE
(
( `b`.`Data` IN ( 'Open', 'Comment', 'Pending Others', 'Work in Progress', 'Resolved' ) )
AND (
NOT (
`b`.`IssueId` IN (
SELECT
`c`.`IssueId`
FROM
`SIM_FE_Audit_Data` `c`
WHERE
( ( `b`.`Actual Create Date` = `c`.`Actual Create Date` ) AND ( `b`.`Data` = 'Comment' ) AND ( `c`.`Data` = 'Open' ) )
)
)
)
)
ORDER BY
`b`.`IssueId`,
`b`.`Actual Create Date`
) `b` ON `b`.`Id` = `a`.`IssueId`
WHERE
NOT a.Title LIKE '%test%'
这是结果查询;现在我必须弄清楚如何从中创建一个视图。到目前为止,它并不想让我,但这是一个不同的问题,因为它可能需要我重写所有内容。
我会将赏金奖励给Mocking,因为他们的回答是99%的查询表。
答案 0 :(得分:1)
我已编写此查询并对其进行了测试。 它根据您的要求为您提供行。 您可以通过添加唯一ID轻松删除所需的行。
SELECT
*
FROM
(
SELECT
t1.issue_id as t1_issue_id,
t1.path as t1_path,
t1.data as t1_data,
t1.acd as t1_acd,
t2.issue_id as t2_issue_id,
t2.path as t2_path,
t2.data as t2_data,
t2.acd as t2_acd
FROM
MY_TABLE_NAME as t1
LEFT JOIN
(
SELECT
*
FROM
MY_TABLE_NAME
WHERE
`data` LIKE "Comment"
) as t2
ON
t1.issue_id = t2.issue_id
WHERE
t1.`data` LIKE "Open"
) as t3
WHERE
t1_acd = t2_acd
此处acd代表实际创建日期 希望它有所帮助
答案 1 :(得分:0)
我反对我更好的判断。
UIViewController
这是基于OP在撰写此答案时所述的所有信息。
我个人知道不应将enabled
用作密钥。