Need help in understanding a SELECT query

Posted by Grant Smith on Stack Overflow See other posts from Stack Overflow or by Grant Smith
Published on 2011-01-12T12:29:00Z Indexed on 2011/01/12 12:53 UTC
Read the original article Hit count: 149

Filed under:
|
|
|

I have a following query. It uses only one table (Customers) from Northwind database. I completely have no idea how does it work, and what its intention is. I hope there is a lot of DBAs here so I ask for explanation. particularly don't know what the OVER and PARTITION does here.

WITH NumberedWomen AS
(
    SELECT CustomerId ,ROW_NUMBER() OVER 
            (
                PARTITION BY c.Country 
                ORDER BY LEN(c.CompanyName) ASC
            ) 
                women 
                FROM Customers c
)

SELECT * FROM NumberedWomen WHERE women > 3 

If you needed the db schema, it is here

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server