私は見解を持っています:
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」などの他の列では正常に動作しています。
なぜこうなった?