我有一个看法:
SELECT
u.display_name AS usuario,
g.parent_name AS grupo,
pr.pkey,
REPLACE(
CONVERT (VARCHAR, ji.CREATED, 111),
'/',
'-'
) AS fecha,
CAST (ji.issuetype AS INT) AS issuetype,
a.customvalue AS aplicativo,
m.customvalue AS modulo
FROM
jiraissue AS ji
JOIN project pr ON pr.ID = ji.PROJECT
JOIN (
SELECT
ms.*
FROM
cwd_membership ms
INNER JOIN cwd_group gp ON (
gp.ID = ms.parent_id
AND group_name IN (
'Grupo QA 1',
'Grupo QA 2',
'Grupo QA 3',
'BH Seguros Homo'
)
)
) g ON g.lower_child_name = ji.REPORTER
JOIN cwd_user u ON g.lower_child_name = u.user_name
JOIN (
SELECT
ISSUE,
customvalue
FROM
customfieldvalue v
INNER JOIN customfield f ON (
f.ID = v.customfield
AND f.cfname = 'Aplicativo'
)
INNER JOIN customfieldoption o ON (o.ID = v.STRINGVALUE)
) a ON (a.ISSUE = ji.ID)
JOIN (
SELECT
ISSUE,
customvalue
FROM
customfieldvalue v
INNER JOIN customfield f ON (
f.ID = v.customfield
AND f.cfname = 'Módulo'
)
INNER JOIN customfieldoption o ON (o.ID = v.STRINGVALUE)
) m ON (m.ISSUE = ji.ID)
WHERE
ji.issuetype IN (9, 11, 12, 13, 14, 15)
GROUP BY
ji.issuetype,
pr.pkey,
g.parent_name,
u.display_name,
REPLACE(
CONVERT (VARCHAR, ji.CREATED, 111),
'/',
'-'
),
a.customvalue,
m.customvalue
这给了我这样的东西:
usuario grupo pkey fecha issuetype aplicativo
----------------------------------------------------------------------------------
Ricardo A. Casares Grupo QA 1 GD123 2012-11-23 12 Act-creditos-scheduler ABM_Suc-backend
然后,当我尝试查询这个视图时,让我们说一个简单的查询:
SELECT * FROM view
WHERE pkey LIKE '%GD123%'
在某些列中,我收到“将数据类型 nvarchar 转换为数字时出错”但在其他一些列中,例如“aplicativo”,它工作正常。
为什么会这样?