Answers for "how to get value by fixed row num in sql"

SQL
4

ms sql row_number over partition

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;
Posted by: Guest on January-28-2020
0

create row number in sql

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;
Posted by: Guest on July-24-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language