Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL: Column populated by other table column names

Status
Not open for further replies.

atiaran

Programmer
Apr 30, 2003
31
GB
Hello people

I've got this question.
I have a view which has a column referring to the names of different columns in different tables and of different types.

view: vw_call_history

HISTID CALLNO COL-NAME PRE-VALUE CURR-VAL
50620 22038 OWNERID 16220 <NULL>
50620 22038 ASSIGNEDTIME <NULL> 1168614660115
50907 22038 ISREAD 1 0
52619 22038 QUEUEID 1 2
52619 22038 CREATEDTIME 1167823803661 170168001555
52619 22038 ISESCALATED 1 0
52619 22038 OWNERID 16220 17119
52619 22038 ASSIGNEDTIME 1168614660115 1170168001555
52620 22038 QUEUEID 2 1
52620 22038 CREATEDTIME 1170168001555 1170169859616
52620 22038 OWNERID 17119 16220
52620 22038 ASSIGNEDTIME 1170168001555 1170169859616
53227 22038 RESOLUTION <NULL> IS CLOSED

My question is: how can I create my query so that I can address those different columns (OWNERID, ASSIGNEDTIME,QUEUEID, CREATEDTIME ...) separately.

For example: for the line below
52619 22038 OWNERID 16220 17119
the explanation is as follow:

Previously the call number 22038 had the ownerid 16220 (PRE-VALUE) and then later on changed to the ownerid 17119 (CURR-VALUE).

In order for me to know the name for the ownerid (16220 or 17119) I would have to join that view with another table, which has got the owner details. However, I cannot do that straightaway because in the column COL-NAME there are also different column name with different data type.

Could someone please help me to determine how I can do my query in order to get any relevant details linked with that COL-NAME.

Please help I am so desperate. Your help is very much appreciated.

Thanks
Atia


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top