SQL query of splitting the data of dynamic field and put it into one row

Moderator: crythias

Locked
gecelann
Znuny expert
Posts: 164
Joined: 12 Feb 2016, 08:05
Znuny Version: 5.0.0
Real Name: ann
Company: rghdinc

SQL query of splitting the data of dynamic field and put it into one row

Post by gecelann »

Hi!

Good day!
I already created the query of the dynamic field and split it into different temporary columns but the thing is, it has a null values which i would like to get rid as what the image shown below. Is it possible to split the data of the column (dynamic_field_value.VALUE_TEXT) and put it into one row?


This is my sample query.

SELECT ticket.tn,
article.a_body as Issue_description,
article.a_subject as Store_challenge,
article.create_time,
CASE
WHEN dynamic_field_value.field_id = 6 then dynamic_field_value.VALUE_TEXT
END AS Category,
CASE
WHEN dynamic_field_value.field_id = 5 then dynamic_field_value.VALUE_TEXT
END as Sub_category,
CASE
WHEN dynamic_field_value.field_id = 4 then dynamic_field_value.VALUE_TEXT
END as Service_type

FROM article
JOIN ticket on article.ticket_id=ticket.id
LEFT JOIN dynamic_field_value on dynamic_field_value.object_id = article.ticket_id
WHERE ticket.tn = '20160501040'
AND (dynamic_field_value.VALUE_TEXT IS NOT NULL OR dynamic_field_value.VALUE_TEXT != 0)


And the result is in the attachment.

Please help me to figure out how to get rid null values in my temporary columns.
It would be a great help for me to improve my sql knowledge. Thanks alot!!! :D
You do not have the required permissions to view the files attached to this post.
Locked