Results 1 to 4 of 4

Thread: There Can Be Only One!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    Australia
    Posts
    27

    There Can Be Only One!

    Need an SQL statement (or similar Microsoft Access trick) which queries a table and only produces the first occurence of a field called item and puts info of the next occurance(s) into a new field called info(x)

    item___info
    1_____1111
    2_____2222
    2_____222a
    2_____n/a
    3_____bla bla bla
    3_____brother
    3_____sister

    will become:

    item___info_____info2_____info3
    1_____1111____ _____
    2_____2222____222a_____
    3___bla bla bla___brother___sister

    I have been able to produce the fields info(x) and populate them appropriatly, however using item=3 in the example above I would actually get 3 records for when item=3 (one for each info(x) value)... so it would look like this

    item___info_____info2_____info3
    1_____1111____ _____
    2_____2222____222a_____
    2_____2222____222a_____
    3___bla bla bla___brother___sister
    3___bla bla bla___brother___sister
    3___bla bla bla___brother___sister

    In any case the statement I used for this was very very messy and I'm sure there should be a way to incorporate both the population of info(x) as well as the exclusion of any duplicated value whilst leaving the first occurance of that value in one SQL statement.

    For the data I am using there will be a maximum of 5 possible info fields.

    Hopefully the problem is clear enough, and the solution is easy enough.

    Thanks in advance.
    Q.

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    I can probably do that in code, but in Sql.. hmm not sure.

    If you are using Sql server, you might be able to implement a procedure on it? where the server does all the manouvering for you into the correct places.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Location
    Australia
    Posts
    27
    unfortunatly i don't have access to edit anything on the server... just read only access.

    I import the relevant tables from the SQL server as a dynamic link and play wiht them in Access, thus anything before retreival of the tables I am unable to change!

    So it has to be done in SQL unfortunatly.

    any suggestions?

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    You import from Sql Server to access... so use code in access to format a report table the way you want in code.

    Should be able to achieve what you need.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Click Here to Expand Forum to Full Width