Question

For the following question: In a table called AllColors there are columns called Colors and ColorName....

For the following question: In a table called AllColors there are columns called Colors and ColorName. In another table called Items there are columns called ItemID, ItemName, SupplierID, and the connecting column which Colors. Return the Colors, ColorName, and the count items for each color. And order results by the count, DESC,

I have the following answer:

SELECT Colors, ColorName, COUNT(*) as cnt

FROM AllColors A, Items I

WHERE A.Colors = I.Colors GROUP BY Colors, ColorName

ORDER BY cnt DESC;

However, it is almost correct, I should be getting 36 rows, but I'm only getting 7. there are null colors. and when I add the following in the where clause I get 36 rows but the results are incorrect, (WHER A.Colors = I.Colors OR (I.Colors IS NULL))

PLZ HELP!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SELECT A.Colors, ColorName, COUNT(*) as cnt

FROM AllColors A, Items I

WHERE A.Colors = I.Colors

GROUP BY A.Colors, ColorName

ORDER BY cnt DESC;

If any results are incorrect, please provide table data for better output...

Let me know if you have any clarifications. Thank you

Add a comment
Know the answer?
Add Answer to:
For the following question: In a table called AllColors there are columns called Colors and ColorName....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT