Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

median value in sql server 2008?

I have a homework problem for my database class that requires me to find the median value. I've spent almost an hour on this one problem and I can't get anything to work.

Here is the question.

Write a SELECt statement that answers this question: Which invoices have a PaymentTotal that's greater than the median PaymentTotal for all paid invoices? Return the InvoiceNumber and InvoiceTotal for each invoice

The book gives also me this 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.

Code for number 2 is below.

Select Invoicetotal, invoicenumber, paymenttotal

from Invoices

where PaymentTotal >

(select avg (paymenttotal) as averagepayment

From Invoices)

Any help would be greatly appreciated

Thanks!

2 Answers

Relevance
  • Anonymous
    9 years ago
    Favorite Answer

    sql

    -----------

    query

    ----------

    (vari.1)int. 50% ››››pay.out

    }

    prompt.int«5.0, repl.

    int.

    {5 = 0 • 0 • 5}*

    Next,

    Sql.html ›› int.pay.repl.

    2

    }{ 2 * 2[6]

    Divide Code,

    2.0 = Med.val.

  • ?
    Lv 4
    4 years ago

    sq. makes no ensures with regard to the order information are stored in. whilst an id column supply you a column to style on interior the order the products have been inserted, even those could come returned in a different order in case you do no longer specify a style order.

Still have questions? Get your answers by asking now.