dimanche 28 juin 2015

Create a view of an account showing hierarchy of tags

we have a database structured as follows:

-Cnsmr_accnt_tag Table (Important fields cnsmr_accnt_id, tag_id)
-Tag Table (Important fields Tag_id, tag_nm, Tag_typ_id)
-Tag_typ Table (Important fields Tag_typ_id, Tag_typ_nm)

The cnsmr_accnt can have multiple tags. Some types of tags are exclusive and other types are not.

So we have an exclusive tag type called 'Area'. (Tag_typ.tag_typ_nm = 'Area') and an account will only have tag with type 'Area'. Then within this we have another exclusive tag type called 'Process'. And finally we have a bunch of other tags which are non-exclusive.

So an account will be in one area and one process but could then have multiple non-exclusive tags.

I am trying to create a query to present data as follows:

CNSMR_ACCNT_ID       |    AREA_TAG     |     PROCESS TAG     |     OTHER TAGS
12345                |Prelegal         |   Early Stage       | System Status Tag
12345                |Prelegal         |   Early Stage       | Active Tag
12352                |Prelegal         |   Early Stage       | System Status Tag
12352                |Prelegal         |   Early Stage       | Active Tag
12370                |Legal            |   Early Stage       | System Status Tag
12370                |Legal            |   Early Stage       | Active Tag
12370                |Legal            |   Early Stage       | Other Tag1
12370                |Legal            |   Early Stage       | Other Tag2

Any suggestions as to how to do this?

Aucun commentaire:

Enregistrer un commentaire