Results 1 to 1 of 1

Thread: Column alias

  1. #1
    Member
    Join Date
    2009-09
    Posts
    3
    Login to Give a bone
    0

    Default Column alias

    I would like to put column aliases on some of the fields in the SELECT statement.

    Code:
    Private Sub CommandButton1_Click()
    Dim NumList As String
    Dim SourceBook As Workbook
    Dim ListSheet As Worksheet
    Dim QuerySheet As Worksheet
    Dim Query As QueryTable
    Dim Numb As String
    
    Set SourceBook = Application.ActiveWorkbook
    Set ListSheet = SourceBook.Worksheets("Main")
    Set QuerySheet = SourceBook.Worksheets("MONEY")
    Numb = Range("H6")
    
    
    If ListSheet.Cells(6, 8).Value = "" Then Exit Sub
    NumList = "'" & ListSheet.Cells(6, 8).Value & "'"
    
    Set Query = QuerySheet.QueryTables("MNY")
    Query.Sql = "SELECT NUMB_TBLE.NUMB_NAME, extract(month from NUMB_DATES_TBLE.DAY_MTH_YR) " _
    & "FROM JES.NUMB TBLE NUMB TBLE,
    JES.NUMB_DATES_TBLE NUMB_DATES_TBLE" _
    & "WHERE NUMB_TBLE.NUMB_ID = NUMB_DATES_TBLE.NUMB_ID AND NUMB_TBLE.NUMB_CODE IN (" & NumList & ") " _
    & "Group by numb_tble.numb_name, 
    extract(month from NUMB_DATES_TBLE.DAY_MTH_YR)
    
    
    
    
    Query.Refresh (False)
    
    
    End Sub
    I want to alias the column NUMB_TBLE.NUMB_NAME, I want it to say LAST_NAME

    I have tried NUMB_TBLE.NUMB_NAME AS LAST_NAME. It works but it changes the order of the columns. I do not want the order of the columns to change.

    When the query runs, in Excel, the column headings are DAY_MTH_YR and LAST_NAME

    If I do not use the alias, the column headings in Excel are NUMB_NAME, DAY_MTH_YR.

    I want the order to still be Name of the person, Date of the transaction.

    When I use the alias, it becomes Date of the transaction, Name of the person

    The order changes.

    How do I alias the columns without effecting the order of the columns.

    I connect to the Oracle database and the result set is put into excel
    Last edited by RobertB; 2009-09-23 at 08:21 PM. Reason: Added [code] tags

Similar Threads

  1. Graphical Column Schedule - Column Location Marks
    By robin.156592 in forum Revit Structure - General
    Replies: 6
    Last Post: 2010-04-05, 05:08 PM
  2. Graphical column schedule - issue with column location mark
    By brent.vanlelyveld in forum Revit Structure - General
    Replies: 4
    Last Post: 2009-05-21, 07:58 PM
  3. Graphical Column Schedule and slab/column intersection not show correct in GCS
    By jonas.152865 in forum Revit Structure - General
    Replies: 3
    Last Post: 2008-07-16, 06:58 AM
  4. Column Grid Lines and Shifting Column Grids
    By .chad in forum ACA General
    Replies: 4
    Last Post: 2007-11-02, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •