MS access - queries

Discussion in 'OT Technology' started by tez, Jun 1, 2005.

  1. tez

    tez OT Supporter

    Joined:
    Mar 15, 2005
    Messages:
    63
    Likes Received:
    0
    Location:
    /home
    Hey all,

    Im just trying to do a query (in preperation for an exam) although Ive got a bit of trouble doing this.

    Im using design view.

    Im working through this book and its got a question asking me to use an expression to create a new field in a table which is say 25% less than the price in the existing table.

    To make it clearer, for example, there is a table with a field Price. It wants me to create a new field call Discount, where it adds a new column to the table with Price * 0.75.

    I think its done using a update query, but not 100% sure.

    Any ideas?

    Thanks
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,924
    Likes Received:
    11
    Location:
    Los Angeles
    ALTER (table name) ADD Discount INT NOT NULL;
    UPDATE (table name) SET Discount = ((SELECT Price FROM (table name) * .75);
     
  3. tez

    tez OT Supporter

    Joined:
    Mar 15, 2005
    Messages:
    63
    Likes Received:
    0
    Location:
    /home
    Im assuming thats SQL? The book Im working through is just basics. Ie using design view. any hints that way?
     
  4. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    You can't do that in design view. If you don't want to add the field but jsut display a field that is 25% off then in design view you just put

    Discount: [Price] * 0.75

    In a new column. Otherwise you gotta do via raw SQl commands
     

Share This Page