Hello at all,
I have a SQL Statement for generating a report that gives me all Incidents with some more Informations. For a few custom field i have some subquerys that work fine if there run alone. If there run as sub query at the complete statement they return more than one row.
The Statement: Sub Q's are underlined. One Query for each Customfield
SELECT
ji.issuenum AS "Incident ID",
issuestatus.pname AS "Incident Status",
ji.priority AS Priorität,
-- ji.component AS "Kategorie betroffenes Produkt",
-- ji.component AS "Kategorie verursachendes Produkt",
(SELECT cfo.customvalue FROM customfieldvalue cfv, customfieldoption cfo, jiraissue ji, issuetype it where cfv.customfield = 10139 and
cfv.customfield = cfo.customfield and
CAST(cfv.stringvalue as SIGNED) = cfo.id and
cfv.issue = ji.id and
ji.issuetype= "10002") AS "Umgebung",
(SELECT cfo.customvalue FROM customfieldvalue cfv, customfieldoption cfo, jiraissue ji, issuetype it where cfv.customfield = 10133 and
cfv.customfield = cfo.customfield and
CAST(cfv.stringvalue as SIGNED) = cfo.id and
cfv.issue = ji.id and
ji.issuetype= "10002") AS "Sicherheitsrelevant",
(SELECT cfo.customvalue FROM customfieldvalue cfv, customfieldoption cfo, jiraissue ji, issuetype it where cfv.customfield = 10135 and
cfv.customfield = cfo.customfield and
CAST(cfv.stringvalue as SIGNED) = cfo.id and
cfv.issue = ji.id and
ji.issuetype= "10002") AS "Datenschutzrelevant",
(SELECT cfo.customvalue FROM customfieldvalue cfv, customfieldoption cfo, jiraissue ji, issuetype it where cfv.customfield = 10132 and
cfv.customfield = cfo.customfield and
CAST(cfv.stringvalue as SIGNED) = cfo.id and
cfv.issue = ji.id and
ji.issuetype= "10002") AS "TI-NOTFALL",
DATE_FORMAT(ji.created, '%Y-%m-%dT%T%+02' ) AS "Zieltermin",
ji.reporter AS "Incident Melder",
ji.assignee AS "Incident Bearbeiter",
ji.summary AS "Incident Beschreibung",
-- DATE_FORMAT(ji.duedate, '%Y-%m-%dT%T%+02' ) AS "Zieltermin",
resolution.pname AS "Indicent Lösung"
FROM jiraissue ji join project on ji.project=project.ID
join issuetype on ji.issuetype=issuetype.ID
join issuestatus on ji.issuestatus=issuestatus.ID
left outer join resolution on ji.resolution=resolution.ID
where ji.issuetype = "10002";
As I said. If I run this:
SELECT cfo.customvalue FROM customfieldvalue cfv, customfieldoption cfo, jiraissue ji, issuetype it where cfv.customfield = 10139 and
cfv.customfield = cfo.customfield and
CAST(cfv.stringvalue as SIGNED) = cfo.id and
cfv.issue = ji.id and
ji.issuetype= "10002"
I get the correct table of results.
Can anybody help me?
Best regards,
Stephan