question

MWood avatar image
MWood asked

I do not know how to write this query.

Write a SELECT statement that answers this question: Which invoices have a PaymentTotal that’s greater than the median PaymentTotal for all paid invoices? (The median marks the midpoint in a set of values; an equal number of values lie above and below it.) Return the InvoiceNumber and InvoiceTotal for each invoice. Hint: Begin with the solution to exercise 2, then use the ALL keyword in the WHERE clause and code “TOP 50 PERCENT PaymentTotal” in the subquery. */
sqlhomeworksubquery
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Total and complete homework question. Someone is likely to answer it, but, usually, most of us will ask you to show what work you have done and then help you from there. After all, if I write the query, I should get the grade, right? Which bits have you hung up?
2 Likes 2 ·
Dave_Green avatar image Dave_Green ♦ commented ·
The question is obviously looking for a particular form of answer - if you provide the solution to "exercise 2" (which presumably you have answered) then we may be better able to provide an answer in the form looked for (there are usually many ways of getting a similar answer). For example, you may choose to use row number rather than top 50 percent, or a CTE rather than a subquery. You've stated you don't know the answer - but outlining your thought processes and how far you've gotten will provide us with confidence that we're helping you learn, rather than simply doing your homework for you!
2 Likes 2 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.