Chocolate
0
Q:

rownum in sql

USE AdventureWorks2012;  
GO  
SELECT FirstName, LastName, TerritoryName, ROUND(SalesYTD,2,1) AS SalesYTD,  
ROW_NUMBER() OVER(PARTITION BY TerritoryName ORDER BY SalesYTD DESC) 
  AS Row  
FROM Sales.vSalesPerson  
WHERE TerritoryName IS NOT NULL AND SalesYTD <> 0  
ORDER BY TerritoryName;  
4
SELECT *
FROM table
WHERE condition
GROUP BY expression
HAVING condition
{ UNION | INTERSECT | EXCEPT }
ORDER BY expression
LIMIT count
OFFSET start
3
SELECT t.A, t.B, t.C, ROW_NUMBER() OVER (ORDER BY t.A) as newId
  FROM dbo.tableZ AS t
  ORDER BY t.A;
0

SELECT MAX(column_name)

FROM table_name

WHERE condition; 
2
Syntax:
SELECT TOP number|percent column_name(s)
FROM table_name
WHERE condition;

Example:
SELECT TOP 3 * FROM Customers;
-1
SELECT TOP 1000 *
FROM Customer;
1
SELECT ROWNUM, a.*
FROM (SELECT customers.*
      FROM customers
      WHERE customer_id > 4500
      ORDER BY last_name) a;
0

New to Communities?

Join the community