我有一个问题,我想返回一个表,每个票id一行。
SQL查询
SELECT
tickets.tid,
CASE WHEN ticketnotes.message
LIKE '%https://xxxx.zendesk.net/.../%'
THEN ticketnotes.message
ELSE '-' END as escalated,
CASE WHEN ticketnotes.message
LIKE '%Ticket ID%Issue Summary%Suggested Solution%'
THEN ticketnotes.message
ELSE '-' END as message
FROM
tickets
INNER JOIN ticketnotes ON ticketnotes.ticketid = tickets.id
WHERE
tickets.status = 'Closed'
AND tickets.did = 7
AND DATE(tickets.date) BETWEEN DATE('2020-04-01') AND DATE('2020-04-30')
输出
目标是返回一个具有唯一票证id的表,如果票证id中有消息或升级消息,则在列中返回它。如果没有,返回 -
. 正确的输出,如果一个票证id升级和消息,要在一行3列,如图所示。
1条答案
按热度按时间hk8txs481#
试试这个: