Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jan Lundeen
6,201 PointsUNION ALL didn't bring back a union of all fruits and vegies (Querying Relational Databases, Challenge 3 of 6)
Hi,
In the Querying Relational Databases Class, my UNION ALL query didn't bring back a union of all fruits and vegetables.
Here's the question: Challenge 3 of 6:
There are two tables Fruit and Vegetable table. The Fruit table has a FruitID and a Name column and the Vegetable table has a VegetableID and Name column. Create a list of fruits and vegetables that includes any potential duplicate values. Ensure that it is in alphabetical order so that the duplicates are next to each other!
Here's my query:
SELECT Name FROM Fruit UNION ALL SELECT Name FROM Vegetable ORDER BY Name DESC; I got a table listing Zucchini, Zucchino, Yams, Winter Melon
And I got the following error message:
Bummer! Your UNION queries didn't bring back a union of all fruits and veggies (including duplicates).
My query appears to follow the UNION ALL format. I made sure to use the same columns on each side (Name). I'm not sure why I'm getting this error message. Any ideas?
Thanks,
Jan
2 Answers
Steven Parker
243,201 PointsRight data, wrong order?
The challenge said, "Ensure that it is in alphabetical order" but your query specifically returns reverse alphabetical order using the DESC keyword.
Try it without "DESC".
Lucian Rotaru
4,983 PointsSELECT Name FROM Fruit UNION ALL SELECT Name FROM Vegetable ORDER BY NAME;
Steven Parker
243,201 Points FYI: Explicit answers without any explanation are strongly discouraged by Treehouse and may be redacted by staff or moderators.
Jan Lundeen
6,201 PointsJan Lundeen
6,201 PointsHi Steven,
Thanks for the feedback. From that error message, I wouldn't have thought that's what it was.
You were right. Great catch!
Thanks,
Jan