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?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|||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.
No comments:
Post a Comment