SELECT
owner AS __group__,
(CASE status WHEN 'closed' THEN 'color: #aaaaaa'
ELSE ''
END) AS __style__,
(CASE status WHEN 'assigned' THEN 4
ELSE 3
END) AS __color__,
id AS ticket,
(CASE status = 'closed'
WHEN 0 THEN
(CASE (round(julianday(substr(tc.value,7,4) ||
'-' || substr(tc.value,1,2) || '-' ||
substr(tc.value,4,2))) - round(julianday('now'))) < 0
WHEN 0 THEN (round(julianday(substr(tc.value,7,4) || '-' ||
substr(tc.value,1,2) || '-' || substr(tc.value,4,2)))
- round(julianday('now')))
ELSE '超時' || abs((round(julianday(substr(tc.value,7,4) || '-' ||
substr(tc.value,1,2) || '-' || substr(tc.value,4,2)))
- round(julianday('now')))) || '天'
END)
ELSE ''
END) AS '距截止天數',
tc.value AS '預估截止日',
status,
priority,
summary,
t.type AS type,
time AS created,
changetime AS _changetime,
description AS _description,
reporter AS _reporter,
tc2.value AS '_due assign',
date('now') as _nowdate,
julianday('now') AS _nowdate2
FROM ticket t,enum p, ticket_custom tc, ticket_custom tc2
where
t.id = tc.ticket AND
tc.name = "due_close" AND
t.id = tc2.ticket AND
tc2.name = "due_assign" AND
p.name=t.priority AND
p.type='priority' AND
t.milestone='**指定里程碑**'
ORDER BY owner, (status = 'closed') ,p.value, t.type, time