Can I label the output column resulting from a SELECT query with a variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cbjones
    New Member
    • Apr 2010
    • 9

    #1

    Can I label the output column resulting from a SELECT query with a variable

    Can I lable the output column resulting from a SELECT query with a variable from one of the tables which are the source of the data? I know I can hard code the lables in the SELECT statement but since the actual data will not always be “ ½ nuts”, for instance, I want the column to be called whatever is in that field.

    I am not sure I have been clear here…hoping so!

    In other words, if I have a table containing

    Column Name |Data
    Data1 |1/2 inch nuts
    Data2 |3/8 inch bolts
    Stock1 |0.08
    Stock2 |0.12


    Normal SQL SELECT query result
    Data1 |Data2 |Stock1 |Stock2
    0.0800 |0.1200 |0.08 |0.12

    Desired SQL SELECT query result
    1/2 inch nuts |3/8 inch bolts
    0.0800 |0.1200

    Many Thanks!
    CBJ
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Not without some tricky dynamic sql which, judging from what I see in your question, could be very tricky indeed.

    Comment

    Working...