Results 1 to 7 of 7

Thread: add column

  1. #1
    Join Date
    Apr 2004
    Posts
    15

    Post Unanswered: add column

    I have table with column A and B in numeric which created using sql SELECT INTO.Now i want to add a column C with value C=A/B.any suggestion?

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Quote Originally Posted by koesk
    I have table with column A and B in numeric which created using sql SELECT INTO.Now i want to add a column C with value C=A/B.any suggestion?
    Do it throught your Create Table Query like that:
    PHP Code:
    SELECT TBL.ATBL.B, [A]+[B] AS C INTO yourTempTable
    FROM TBL

    Where TBL is your original table, A is the first filed you want to add, B is the second filed you want to add, and C is their sum. yourTempTable is the created Table

  3. #3
    Join Date
    Apr 2004
    Posts
    15
    ok thanks...but is it possible to add the column into the table which contain column A and B without create a new or temp table?I have a large table and it takes long time to create a new table.

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Sure you can do the same in your original Table

    Good Luck

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Post

    Here is the Syntax again:
    PHP Code:
     SELECT yourOriginalTable.AyourOriginalTable.B, [A]+[B] AS 
        FROM  yourTempTable


  6. #6
    Join Date
    Apr 2004
    Posts
    15
    ok i've created a column using UPDATE [table1] SET [C] = A/B.how can i change the column C to Percent format?i've tried UPDATE [table1] SET [C] = FORMAT(A/B,'##0.000%') but it results a blank column?some help please....

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Arrow

    Quote Originally Posted by koesk
    ok i've created a column using UPDATE [table1] SET [C] = A/B.how can i change the column C to Percent format?i've tried UPDATE [table1] SET [C] = FORMAT(A/B,'##0.000%') but it results a blank column?some help please....
    Try something like that:
    PHP Code:
     SELECT TBL.ATBL.BFormat(([A]+[B])/100,"#%") AS C
        FROM TBL


Posting Permissions

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