Results 1 to 11 of 11
  1. #1
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28

    Query to display in single row

    Hi,

    I have two tables
    T1
    TID | Len
    22----2

    T2
    TID | Len2
    22-----3
    22-----4

    I need a query to display
    TID | Len | DiffLen1 | DiffLen2.....|DiffLenn
    22----2----1(3-2)-----2(4-2)------....

    I'm able to write a query as below:
    SELECT T1.TID, T1.Len, T2.Len2-T1.Len FROM T1 INNER JOIN T2 ON T1.TID = T2.TID;

    But this display entries as:
    TID | Len | DiffLen
    22----2----1(3-2)
    22----2----2(4-2)


    ....

    How can i change my query to display in a single row Please help me out in this regard. Thanks.

  2. #2
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    Can any one please help on this. Thanks in advance

  3. #3
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    Please let me know if i'm not clear.

  4. #4
    jbarrum is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2009
    Location
    Houston, Tx
    Posts
    164
    Hello,

    I think I will be able to help but I am unclear as to what your fields are and what data type that they hold. Can you clarify

  5. #5
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    Thanks for your reply.
    For table T1
    TID, Len are the fields of type Number
    also For table T2
    TID, Len2 are the fields of type Number

    I'm able to write a query as below:
    SELECT T1.TID, T1.Len, T2.Len2-T1.Len FROM T1 INNER JOIN T2 ON T1.TID = T2.TID;

    But this display entries as:
    TID---Len----DiffLen
    22-----2-----1(3-2)
    22-----2-----2(4-2)

    I would like to display it as:
    TID---Len---DiffLen1---DiffLen2---DiffLenN
    22-----2----1(3-2)-----2(4-2)------....

  6. #6
    jbarrum is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2009
    Location
    Houston, Tx
    Posts
    164
    ok, i thnk i understand now. you need to create a releationship between table 1 and tble 1 by linking the field TID. However, I have a concern that you are creating a normalization problem. Why is TID being stored in two differnt tables?

  7. #7
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    Thanks for your reply. There tables are pre-existing. So, i havent thought about the design and i'm not supposed to change the design. My task is to just write a query to appear in single row.

  8. #8
    jbarrum is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2009
    Location
    Houston, Tx
    Posts
    164
    I understand. Trying ceating the relationship between the two and let me know if that works. You will propably need a outerjoin

  9. #9
    access is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2009
    Posts
    28
    Created a relationship between two tables with TID. But there is no change in the output of the query.

    I'm getting some error when i changed from inner join to outer join.

  10. #10
    jbarrum is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2009
    Location
    Houston, Tx
    Posts
    164
    you will get an error if you have data in the two tables and that data does not meet the criteria of the inner or outer join(whichever one you are trying to do). If you do not get the error then the data meets the criteria of the join.

  11. #11
    jbarrum is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Apr 2009
    Location
    Houston, Tx
    Posts
    164
    if the tables only have test data, then delete the data, create the joine and then re-enter the data and try your query.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple UPDATE in single query
    By nishezaman in forum Access
    Replies: 0
    Last Post: 12-13-2009, 01:40 AM
  2. display query results in a form
    By P5C768 in forum Queries
    Replies: 3
    Last Post: 08-14-2009, 03:02 PM
  3. Replies: 1
    Last Post: 07-07-2009, 01:00 PM
  4. Display Query Value That Requires Input Parameter
    By Access::Student in forum Access
    Replies: 1
    Last Post: 05-29-2009, 08:43 PM
  5. Query to Display Tables & Fields
    By foxerator in forum Queries
    Replies: 0
    Last Post: 04-24-2008, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums