Author Topic: Organizing attributes as columns instead of rows  (Read 1433 times)

lynch80516

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Organizing attributes as columns instead of rows
« on: February 29, 2020, 06:08:59 pm »
I have a number of elements and each element has a number of attributes and each attribute has a number of tagged values

I currently use a query that extracts the attributes and tagged values into tables where each attribute is a row in the table. This approach causes tables to be repeated with most of the same info

What I’d like to be able to do is use the tagged values properties as the table columns and have the values of the tags along with the attribute names as the rows.

Is this possible

John


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 12250
  • Karma: +484/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Organizing attributes as columns instead of rows
« Reply #1 on: February 29, 2020, 07:27:41 pm »
Yes, simply join t_attributeTag multiple times, set the join property to a fixed value in the join condition.

Code: [Select]
select att.Name, att.Type, att.[Default] as 'Value'
, tv1.VALUE as Tag1, tv2.VALUE as Tag2
, att.Notes as Notes
From t_attribute att
left join t_attributetag tv1 on att.ID= tv1.ElementID
and tv1.Property = 'Tag1'
left join t_attributetag tv2 on att.ID = tv2.ElementID
and tv2.Property = 'Tag2'
inner join t_object on  att.Object_ID = t_object.Object_ID   
where att.Object_ID = #OBJECTID#

Geert