Another easy question

  • Question 12 states:

    “List the part number, part descrption, and item class, for each pair of parts that are in the same item class. “ What does this mean? There are more than 2 of each item in any one class and all the info is in the Part table. I did this, is it correct?

    SELECT PART_NUM, DESCRIPTION, CLASS

    FROM PART

    ORDER BY CLASS

    Is there something about pairing.

    There are 10 items and three CLASSES. 5 in one category, 3 in another, 2 in another.

    Thanks in advance

  • Can you elaborate a bit more as this is really not enough info to tell you the result of what you are looking for. Is there anything that causes two records to be related to each other (especially since stating each pair in the question). If so then a join to itself on the table may be in order but I cannot give you a complete answer from this.

  • unfortunately i can't. I thought maybe there would be a ITEM CLASS table, that i could relate to. but there isn't. All the info I have, you have. My teacher is weird!

  • Not sure what to tell you, maybe I would press the teacher to make a bit clearer.

  • I would think you need to selfjoin, returning something like :

    
    
    Part Item Class
    ---- ----------
    1 1
    2 1
    3 2
    4 1

    Would return something like (just partid, no additional fields here).

    
    
    PartA PartB
    ----- -----
    1 2
    1 4
    2 4

    So you would list each combination of two parts that are in the same class.

    This query does this

    
    
    SELECT PartA.Part_Num, PartA.Description,
    PartA.Class, PartB.Part_Num,
    PartB.Description, PartB.Class
    FROM Part PartA INNER JOIN Part PartB
    ON PartA.Class = PartB.Class

    BTW, this query returns duplicates.

    Edited by - NPeeters on 10/15/2003 3:33:59 PM

  • Can you post the data that is in the table/columns?

    -SQLBill

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply