Question about wording(sql)
I just need help understanding what the following questions are asking for.
- List all details about packages. Sort the output by descending package cost within package type.
What I don't get is "within package type" I know t开发者_如何转开发his much: SELECT * FROM PACKAGE, ORDER PACKCOST DESC;
But I don't get the within??
- List the average package cost for packages of each type. Then list only averages for types containing more than one package.
So for this one I guess I should do the average for each type, then the average for each type that has > 1 packages???
Sorry I don't have the tables.
Thanks.
Table fields:
PACKID PACKNAME PACKVER PACKTYPE PACKCOST
The first question wants you to limit the sorting so that it's grouped by package types. So let's say the package types are Box and Letter. First you would list all the Letter packages, by descending cost. Then you would list all the Box packages by descending cost. Your query right now would mix the Box and Letter packages together and the question doesn't want you to do that.
You seem to understand the other question correctly.
For the first question, I would answer
select * from package order by packtype, packcost desc
This will first order the packages by type, and then within each group order them by cost.
精彩评论