6
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQLでRedmineのチケットを抽出する

Last updated at Posted at 2013-07-02

「終了したチケット」以外のチケット(未完了)を抽出する。

SELECT
  *
FROM
  issues I
  INNER JOIN issue_statuses S
    ON I.status_id = S.id
WHERE
  S.is_closed <> 1
SELECT
  *
FROM
  issues I
WHERE
  EXISTS
    (SELECT * FROM issue_statuses WHERE is_closed <> 1 AND id = I.status_id);

その他の条件を追加

SELECT
  *
FROM
  issues I
  INNER JOIN issue_statuses S
    ON I.status_id = S.id
  INNER JOIN trackers T
    ON I.tracker_id = T.id
WHERE
  S.is_closed <> 1 # 未完了(issue_statuses)
AND
  I.status_id = 1 # ステータスID (issue_statuses)
AND
  T.id = 1 # トラッカーID (trackers)
AND
  assigned_to_id IS NULL # 担当者なし (users)
AND
 author_id = 6 # 作成者(users)
AND
 priority_id = 4 # 優先度(1:低め、2:通常、3:高め、4:急いで、5:今すぐ)
AND
  due_date < '2013-03-20' # 期限日
ORDER BY
  due_date DESC
6
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?