Hi @MrFlinstone ,
Welcome to Microsoft Q&A!
Please also refer below:
CREATE TABLE v_jira_custom_fields (Project VARCHAR(100), customfield_id INT, custom_field_name VARCHAR(100), issue_id VARCHAR(100), string_value VARCHAR(255), number_value INT, text_value VARCHAR(MAX), date_value DATE, custom_value VARCHAR(MAX));
INSERT INTO v_jira_custom_fields VALUES
('DAK',1,'Story Type','2222','4455',NULL,NULL,NULL,NULL),
('DAK',2,'Impacted Application','2222','1213',NULL,NULL,NULL,'Diary Application'),
('DAK',3,'Story Points','2222',NULL,6,NULL,NULL,NULL),
('DAK',4,'Start Date','2222',NULL,NULL,NULL,'2021-01-20',NULL),
('DAK',5,'End Date','2222',NULL,NULL,NULL,'2021-01-24',NULL),
('DAK',6,'Ready','2222',NULL,NULL,NULL,NULL,'No')
CREATE TABLE jira_data (issue_id VARCHAR(100), Issue_Name VARCHAR(100), Issue_Type VARCHAR(100),Project VARCHAR(100));
INSERT INTO jira_data VALUES
('2222','Improve performance','Story','DAK')
select * from
(
select a.issue_id,Issue_Name,Issue_Type,a.Project,custom_field_name,COALESCE(cast(number_value as char),text_value,CONVERT(nvarchar(30), date_value, 126),custom_value) Value
from jira_data a
left join v_jira_custom_fields b on a.issue_id=b.issue_id)s
pivot
(max(value)
for
custom_field_name in ([Story Points],[Ready],[Start Date],[End Date])
)p
Output:
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.