• Hugo Kornelis (5/31/2013)


    I don't get it.

    I did get it, in the sense that I think I .understood the tortuous misuse of the English language in the formulation of the question. Whenever highest quantity or highest value is referred to, even if it's called highest for a single customer or highest for an employee or highest for a year the question is not referring to the quantities that the English leads one to expect, but to a different set of values: only the values in a single order are to be considered, not any aggregates. I spotted that when looking at the options for one of the four categories and then answered on the basis that all the values referred to single order amounts - that got it right, but I see from your comments that some values would also have been right with the more normal interpretation of the words. I think it a pretty horrible question, but people can learn from it - how not to choose a grouping id for example (in this case watching the pattern of NULLs is a better way of identifying groups than using the badly chosen grouping id), and people who haven't come across the grouping sets concept before can at least get a view of what that is (although I would have hated to learn it from anything like this).

    First, the idea of the question. We are given SQL to create and populate a table, *and* SQL that (supposedly?) shows the correct answers. Are we supposed to run this? Work it out in our heads? On a SQL Forum, I'd much sooner expect the task to be to WRITE the query to find the correct answers!

    I'll add to that that the query is utterly pointless from the point of view of answering those questions, it would be easier to answer them from the orders table(since they all refer to single orders, not to aggregates other than MAX, which is nowhere used in the query although it's the only one relevant to choosing between the options provided). It is of course possible to answer those questions by looking at the output from that query, that is a good deal harder, in my view, that just looking at the base table.

    I agree with the rest of your comments and don't think I could add anything useful, so I won't waste everyone's time quoting them and agreeing verbosely.

    Tom