Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    3

    Unanswered: Make table question..

    I am new here, and I am sure this is a simple query, but im being forcefed database chores from my job, so i have to teach this stuff to myself/get help from places like this,
    I need help with a query,
    lets say that there are columns a,b,c,d,e,f,g
    if columns c,d,e are the same, than I want the info in column g changed to the info in column b in the first record of that group
    the reason I am doing this is,
    I have like items (sku's) grouped in my database, and i want to create a blanket part number for skus that have matching descriptions which is the information in colums c,d,e,
    I want to link them to the part number of the first product with that description, and add that part number in a new column at the end of the grouped SKU's record

    this is what i start out with

    a b c d e f g
    2 4 5 6 9 8
    2 5 5 6 9 9
    2 7 5 6 0 5
    1 2 3 4 5 6
    1 3 3 4 5 7
    1 4 3 4 5 8
    1 5 3 4 5 9

    i want to end up with
    a b c d e f g
    2 4 5 6 9 8 4
    2 5 5 6 9 9 4
    2 7 5 6 0 5 7
    1 2 3 4 5 6 2
    1 3 3 4 5 7 2
    1 4 3 4 5 8 2
    1 5 3 4 5 9 2

  2. #2
    Join Date
    Jul 2004
    Location
    Dundee, Scotland
    Posts
    107
    There isn't a simple query to do this. It is possible to run a SQL query where you update a field depending on the contents of other fields in the row, but you suggest the process needs to remember the value for the "first record of that group".

    Here is an approach: select all distinct rows form the table where "columns c,d,e are the same", for each row returned, run a new query to " change g to the info in column b in the first record of that group" for all rows in that group.

Posting Permissions

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