Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Bottom Quartile

Author  Topic 

DJJUBES
Starting Member

4 Posts

Posted - 2012-05-20 : 14:49:37
I am trying to display all the distinct orders where the quantity is in the bottom quartile (in other
words, show all the orders which is in the lowest quarter of orders – lowest 25%)

I am working on a Database called Northwind and the columns to include are OrderID and ProductID
Results should look something like this
OrderID .ProductID
10609 . 1
10700 . 1
10722 . 2


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-20 : 15:42:36
[code]
SELECT columns...
FROM
(
SELECT *,NTILE(4) OVER (ORDER BY OrderQty ASC) AS Qr
FROM table
)t
WHERE Qr = 1
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -