Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    0

    Unanswered: Beginner's question to coding

    ok this is for a class assignment so if anyone doesnt want to help thats cool, but its just a small extra credit assignment and we havent gone over it in class and and the book, well is confusing to say the least so here are my questions:

    What is the total weight of different colored parts?

    ok so i have a parts table, with pcolor and pweight in it but i am unsure how to code that, here is kinda what i think it might be, i have no real way to check to see if it is correct though:

    Select sum pweight
    from parts
    where distinct pcolor

    looks horribly wrong so any help is appreciated. here is another one:

    What colored part has total weight greater than 8 units?

    select pcolor
    from parts
    where sum pweight > 8

    ???
    i dunno lol.

    there is a hint that says to use "GROUP BY" and "HAVING" but i dont see how that fits in... any ideas?

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    I'll put the keywords in the proper order; you figure out the rest:

    SELECT
    FROM
    WHERE
    GROUP BY
    HAVING

    Notes:
    1. I don't think you need the WHERE clause in this particular exercise at all.
    2. You won't need HAVING in the first part

    HAVING was just so totally cool when I first learned how to use it. It is enormously useful at times.

    Regards,

    hmscott
    Have you hugged your backup today?

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    This is a super intro to SQL - you will figure out your answers in no time:
    http://www.w3schools.com/sql/sql_intro.asp

    I'll give you another hint - no need for distinct.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

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